Swerve Drive V2 - Coaxial
About
Swerve is the main motion control system for FIRST robotics competition. Usually, four "pods" are placed in each corner of the robot. These pods each contain a wheel that can be angled to any direction. By adding each wheel's vector and rotation component, it allows the robot to rotate and drive at the same time.
Most teams now buy off the shelf swerve drive's and use prewritten code for all the software. This is simply much easier and is what my team did as well. However, I wanted to actually understand how it worked, which led me to create this project.
CAD-(link)
Team 8223's custom swerve drive
Team 2910's 2021 robot performing an obstacle course
Math/Inverse Kinematics
All math was modeled using this desmos made by my physics teacher Mr. Hosey.
Before going into the design, we have to first understand the math behind it. The values we want to know are the speed and angle values each wheel is supposed to be at. To find these values we need to know six things:
1. Intended speed of travel: V
2. Intended direction of travel: θ
3. Intended speed of rotation: w
4. Radius of the robot (1/2 distance between pods): r
5. Time since the action was initiated: t
6. Current angle of the robot: ϕ
With these six values, we can determine the X and Y components of velocity for each pod
Left X component = V * cos(θ + ϕ) - wr * sin(wt)
Left Y component = V * sin(θ + ϕ) + wr * cos(wt)
Right X component = V * cos(θ + ϕ) - wr * sin(wt + 𝜋)
Right Y component = V * sin(θ + ϕ) + wr * cos(wt + 𝜋)
A little bit of Pythagorean theorem and arctangent later and you have the angle and velocity of each wheel
Example Desmos simulation
Build Explanation
Parts
The main chassis is a one-inch-thick piece of plywood. Really anything can be used but I chose wood because it was easy to plan where components would be and drill out mounting holes.
The swerve drive itself is made up of mostly 3d printed parts and a few radial bearings for smoothness. All parts were printed at 25% infill, blue PETG was used for gears, and white PLA for everything else. For extra grip I wrapped the 3d printed wheels in electrical tape.
For the controller I used an ESP32 DOIT DEVKITV1. The bluetooth compatibility allowed me to use an Xbox controller to control the robot. The high processing power of the ESP32 chip also allowed it to easily handle the interrupt pins for each motor encoder.
As one of the more unique components, the battery is an 18V DeWalt drill battery with a variable voltage adapter on it.
To track the robots current angle, I used a 9 axis IMU from Sparkfun
FULL PARTS LIST HERE
CAD walkthrough
The motors mount on the top plate, transferring torque to their respective shafts. The steer motor (left) turns the pod. The pod itself is held in by a large 3 inch bearing that allows it to spin smoothly. In the center of the pod is the drive motor, which is arranged so it can power the wheel no matter the pod's orientation. There are three mounting holes available on each side of the pod for ease of mounting.
Steer motor shaft, pod, and bearing are highlighted.
The steer shaft drives the pod, which is inset into the 3 inch bearing
Drive motor, transfer gear, large bevel gear, and wheel are highlighted
The center drive shaft, located in the middle of the pod, meshes with the transfer gear. While the pod spins, the transfer gear spins around the drive shaft, ensuring that the two gears always mesh. The transfer then gear goes under the pod and meshes with a bevel gear on the face of the wheel.