Unit 7: Advanced FRC Coding
While a swerve drive's movement is impressive, its real power comes from odometry—the use of sensor data to estimate the robot's precise position and heading on the field. It's how the robot knows where it is at all times.
The heart of odometry is a process called dead reckoning. By continuously tracking its direction and speed over time, the robot can estimate its current position relative to where it started. Our swerve drive uses three critical sensors for this.
Every 20 milliseconds, our code takes a snapshot from these sensors to calculate a new estimated position.
In WPILib, a robot's complete position and orientation on the field are represented by a `Pose2d` object. This object is the "address" of our robot, and a successful swerve drive program spends most of its time keeping this object as accurate as possible.
We don't have to write the complex odometry math from scratch. WPILib provides a class, `SwerveDriveOdometry`, that does all the heavy lifting for us. Our job as programmers is to properly feed this class the sensor data it needs to do its job. It takes data from our swerve modules and gyroscope, and in return, it calculates and stores a continuously updated `Pose2d` for the robot.
Question: What three pieces of information are stored in a WPILib `Pose2d` object?