Overview
This lecture explains the fundamental concepts, components, and programming basics of Swerve Drive robotics, focusing on its unique movement capabilities and how to control it using code.
Swerve Drive Fundamentals
- Swerve Drive robots move each wheel to a specific angle and spin wheels to move in any direction regardless of robot orientation.
- Swerve Drives can rotate independently of translational movement, allowing moving and spinning at the same time.
- The robot's rotation is called its "heading."
- Accurate odometry requires a centered gyroscope and precise module alignment.
Components of a Swerve Drive
- A typical swerve drive has 4 swerve modules (each with a drive motor, angle/azimuth motor, absolute encoder), and one gyroscope.
- Consistent component brands are recommended for best compatibility, but YAGSL enables use of mixed hardware.
- Common pitfalls include off-center mass, misaligned gyroscope, or a non-square drivetrain.
Swerve Drive Kinematics
- Swerve module angles and speeds are determined by desired direction and heading.
- Manual calculation of wheel motions is possible, but SwerveDriveKinematics class automates this.
- Module arrangement (order) is critical; usually: Front-Left, Front-Right, Back-Left, Back-Right.
- Use ChassisSpeeds to set robot movement; get SwerveModuleState array to command each wheel.
Swerve Drive Programming Basics
- Use SwerveDriveKinematics to generate the required state for each module from the desired movement.
- SwerveModuleState includes two properties: angle (azimuth) and speed.
- Set each module’s angle and speed according to the computed SwerveModuleState array.
Odometry and Position Tracking
- Odometry tracks robot's position using heading, speed, and module positions.
- Accurate odometry requires continuous updates, often implemented in a periodic function.
- SwerveDriveOdometry (or SwerveDrivePoseEstimator) helps maintain and update robot pose for precision.
Key Terms & Definitions
- Swerve Drive — A drivetrain where each wheel can independently rotate and propel, enabling holonomic movement.
- Azimuth — The angle or direction a swerve wheel faces.
- Heading — The orientation of the robot’s frame of reference.
- Odometry — Process of estimating the robot’s position and orientation.
- SwerveDriveKinematics — Class that calculates required wheel angles and speeds for desired motion.
- SwerveModuleState — Object containing angle and speed for a module.
- ChassisSpeeds — Object describing desired robot linear and angular velocities.
Action Items / Next Steps
- Practice programming swerve drive in simulation or on a physical robot.
- Explore additional examples and documentation for real-world troubleshooting tips.
- Center the gyroscope and ensure module alignment before use.
- Try visualization tools like AdvantageScope or FRC Web Components for debugging.