Unit 7: Advanced FRC Coding
As a programmer, you need to understand the hardware components that make up our swerve drive. Knowing what each part does and how it connects to the control system is essential for writing the correct code to control it.
Our robots are built with four identical swerve modules, one at each corner. Each module is a self-contained unit that handles the drive and steering for a single wheel. From a programming perspective, each module has three primary components we need to control.
This is a motor controller (typically a Spark Max or Talon FX) that controls the speed of the wheel. The code sends a command to this controller to make the wheel spin faster or slower, causing the robot to move.
This motor controller controls the angle of the wheel. The code sends a command to this controller to turn the entire wheel assembly, allowing it to point in any 360-degree direction.
This is a sensor that tells the code the absolute angle of the wheel. Unlike a standard encoder, an absolute encoder (like the CANcoder) knows its exact position even when the robot is first turned on. This is crucial for swerve, as the robot needs to know the angle of each wheel without a manual "zeroing" procedure.
The drivetrain as a whole is made up of these four modules, a central control unit (the roboRIO), and a gyroscope.
Question: In a swerve module, which component is responsible for reporting the wheel's absolute angle, even right after the robot is powered on?