Skip to content

Update FollowerOdometry to take in odometry encoder locations #77

@NathanDuPont

Description

@NathanDuPont

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:

image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    2This issue is good for beginners and will have some slight challengesRobot Software TeamTeam responsible for robot code updatesenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions