Welcome to the Team Gaelhawks swerve code release thread.
Team 230 Swerve Drive Development
Overview:
At Team 230 we took on swerve drive development as an off season project, with the intent to
develop a swerve drive system to use for performance evaluation and potentially at some point for
use as a prototype for a competition robot. We proceeded with the following ground rules (that
seemed pretty good at the time):
1. We would use COTS swerve drive hardware
We didn’t want to simultaneously develop hardware and software solutions for swerve. The
availability of well designed reliable COTS modules made this an easy decision. We chose to
purchase the SDS Mark 4 modules, powered with Falcon motors for drive and steering.
2. We would write all out own swerve specific code, and close all feedback within the Robo
RIO.
Although we are not morally opposed to utilizing high level feedback and control functionality within the Falcon’s internal motor controller, we have had great success in the past with pulling all command and control functionality into the Robo RIO to as large an extent as possible. This has allowed us to much more easily perform system ID on the hardware and develop control system architecture. We wanted to spend more time developing swerve kinematics and control strategies, vs. spending a lot of time on determining interface requirements for existing libraries (although that is also a viable strategy).
Development:
We broke the initial software development into the following areas:
1. Swerve kinematics
2. Module drive velocity control laws
3. Module steering control laws
We prototyped the original formulation in Octave, a high level language that is for the most part
compatible with the MATLAB programming language. Octave is distributed under the GNU Public
License (GPL), and allows us to very rapidly prototype control systems in a high level language that has native support for vectors, matrices, and complex numbers.
The code development proceeded from the bottom up, in the following manner:
1. Establish the ability to drive motors and read encoder positions, velocities, and angles.
2. Establish closed loop control of module drive velocity and steering angle
3. integrate the high level kinematic equations and drive the base around.
After this was complete, we had a fairly significant laundry list of functions and improvements to
implement. In roughly chronological order, we implemented the following functionality:
1. Implement automatic fwd/reverse drive direction to minimize steering angle command
2. Add steering angle compensation to drive velocity to eliminate parasitic drive during steering
3. Develop revised Falcon velocity encoder filtering to improve control bandwidth
4. Incorporate select-able field coordinate/robot coordinate drive modes
5. incorporate gyro stabilized heading control
6. Implement command model filtering, shaping, and deadband to maximize driveability
At the current time we have implemented around 350 lines of simulation code in Octave, and about 800 lines of C++ code for the prototype drive base. This whole process took us around 6 months to complete, working a couple days a week at the most.