-
Notifications
You must be signed in to change notification settings - Fork 3
Description
The FollowerOdometry class is used to perform the odometry calculations on our robot. It takes in data from two encoders and a gyroscope and uses this data to figure out where our robot is located on the field while driving around. In order to transform data from the encoders into an (x, y) coordinate for the robot's current location, we need to perform some math on the values to calculate where we actually are.
This math involves taking the locations of the two encoders and doing some simple trig to figure out how the values of each encoder contribute to the overall position of the robot. Currently, we are hardcoding the locations of these vectors through constants, but are reading the constants from within the FollowerOdometry class. This makes the system a little bit more brittle, as if we wanted to use this class for odometry on multiple robots, we would need to create a new one for each robot.
Instead, we want to change the code such that the following lines:
Are instead passed into the class as two Vector2d (2-Dimensional vector) classes.
FollowerOdometry.cpp is located in the ChangeUp project, under src/v5_hal/firmware/src/odometry.
FollowerOdometry.h is located in the ChangeUp project, under src/v5_hal/firmware/include/odometry.
FollowerOdometry should take in two required parameters:
Vector2d x_encoder_location
Vector2d y_encoder_location
- Update constructor in FollowerOdometry.h with required parameters
- Add Vector2d m_ x_encoder_location and Vector2d m_y_encoder_location as private variables in the class
- Update constructor in FollowerOdometry.cpp with parameters (see how current_pose is passed in)
- Set variables equal to the parameters (x and y encoders)
- Remove lines 23 and 24 (setting x and y encoder locations to constants)
- Update the delta calculations (lines 39 and 40) if the vector name has changed
