This is easily the biggest project I've ever dedicated myself to, and although I could easily explain every last detail, I'll try to keep it concise for your sake.
Swerve drive, as the name implies, is a type of drive train that dictates how the robot can move around the field. There are three other common types of drive trains, swerve drive being the most advanced and complex:
Tank Drive
Holmonic Drive
Mecanum Drive
Unlike other drive systems, swerve drive enables movement in any direction due to the independent rotation of both the wheel and the wheel's direction. Using this paired with some vector algebra, you can control the robot to both rotate and strafe simultaneously. This enables much easier controllability and flexibility for the driver and autonomous software.
I'm the Lead Programmer and Student Mentor on my school's FIRST Robotics Team, and we've all noticed how well a lot of the swerve drive robots at competitions were performing. We've been using tank drive for the past few years, and have seen some success, but it's mostly been a bottleneck. We've never even attempted Coaxial Swerve Drive because of its complexity and cost, but last summer, I decided to bite the bullet. I led and assembled an off-season team, taught workshops, and built the swerve system from the ground up. I ordered the parts, got to work, and learned a lot. A month later, I had a working prototype.
Even though I had it done in only a month, four months sooner than we anticipated, it's not to say it was an easy feat. I had to completely learn control theory from scratch, and scour the internet for solutions to the many problems we encountered. It turns out that coaxial swerve drive is so complicated that there just isn't a lot of information online, and the information that does exist is very spread out and undocumented. Regardless, I implemented control systems and motion profiling to make it as accurate as possible, while implementing custom telemetry and safety features for easy use.
After a few more months of work with both the hardware and software, This is the result:
Eight Rev NEO Brushless motors (four for steer, and four for drive)
Mounted upside down inside the frame for better protection and lower center of gravity
Eight Rev CAN SPARK MAX Motor Controllers to control the motors through a CAN bus interface
Mounted to custom 3d-printed brackets for cable management and modularity
High torque, high speed 1:6.75 drive gear ratio
14.5 ft/s -> 10 mph
Four CTR Electronics CANcoders
rotary magnetic absolute encoders that communicate over the CAN bus for precise steering angle readouts
Precision-milled skeletonized aluminum frames from Swerve Drive Specialties
NavX AHRS IMU Gyroscope using SPI XMP RoboRIO port
4" Colson wheels with a coefficient of friction of 1.0
Teleoperated Driver Control Via Wireless Xbox Controllers
Custom-tuned input curves and headbands
Uses haptic rumble to communicate with the driver
Limits acceleration to prevent tipping
Robot retains heading even if bumped or disturbed
Automatically compensates for the slight curve you get when moving in a straight line while rotating
Fully Autonomous Complex Driving
Fits bezier curves to a set of splines that are defined before the match to execute complex behaviors without driver input
Autonomous paths can be drawn on a virtual field through custom software
Configurable coefficient of friction to compensate for wheel slipping
Tuned using multiple profiled proportional–integral–derivative controllers to get sub-centimeter precision
Compensates for disturbances and collisions using a built-in gyroscope and vision system
Detects April tags to triangulate its own position in 3D space for precision movements
Uses Kalman filtering and linear quadratic estimation to reduce noisy results
Advanced Motion Profiling
Uses Feedforward and profiled PID controllers for each module to maintain precise wheel velocities and directions
Uses built-in motor controllers and encoders to get 1,000 Hz update rates for sub-millisecond adjustments
Seeds the built-in steering encoder with the absolute CANCoder to keep continuity between the reported steering angle and the motor controllers
Safety
All motors and motor controllers have a limit on current draw in Amps to reduce power spikes and retain battery and motor health
They also have a ramp rate limit for this same reason
If motor temperatures ever go beyond 65.0 °C, they are forcibly disabled until they have cooled off
A maximum motor power can be set when testing new code so parts aren't destroyed if something goes wrong
If motor controllers aren't updated every 20ms, they will stop by default
Telemetry and Logging
Almost every aspect of the robot is logged at all times (20,000 data points per second)
The log files are stored as binary, so they have very little overhead
Saved to a USB stick for easy file transfers
Logs are timestamped, so you can rewind the logs and see exactly what went wrong
Full Physics Simulation
The whole chassis can also be entirely simulated
The simulated wheels use flywheel physics and moment of inertia calculations along with empirical data from the motor manufacturer to produce the most realistic simulation
It's so accurate that motion profiling can be done entirely virtually
Any code, including automated and manual driving code, works exactly the same, meaning you can test and develop new software without ever touching the robot.
The field is also simulated, and in 3D, so you can practice driving the robot in an entirely simulated environment.
Because the motors are also simulated, the amount of voltage and current can also be observed over the whole system
This means that the strain on the battery can also be simulated, and can detect brownouts when driving
Ease of Use
Almost all of the math and low-level programming is abstracted away for easy control
Instead of commanding each module, you only need to command the whole robot, and the software handles the rest for you
All the configuration is in a single file
Supports any frame size, wheel size, mass, acceleration, gear reduction, and much more
Logging is simple with an easy utility class
I'm continuing this project with my Senior Capstone, in which I lead a course to teach and pass down my knowledge about Swerve Drive, programming, and electronics. I've essentially been the solo programmer for the robotics team, and If I don't effectively teach some of the younger members of the team what I've learned, they'll have to re-learn everything from scratch.
If you'd like to see more information on my Capstone project, my proposal is linked here