Skip to main content

Odom

Generic odometry class

The relevant outputs are position (an x/y point) and orientation_deg. Requires an inertial sensor for heading. The math uses the Pilons arc method.

note

Chassis uses an odom instance internally and starts it once set_coordinates is called. You usually only need this class directly when building a custom tracking setup.

Methods

set_physical_distances

void set_physical_distances(float forward_tracker_center_distance,
float sideways_tracker_center_distance);

Sets the tracker center distances. The forward tracker center distance is the horizontal distance from the center of the robot to the wheel the sensor measures. The sideways tracker center distance is the vertical distance from the center of the robot to the sideways wheel being measured. If there is no sideways wheel, set its center distance to 0, which is equivalent to a no-drift robot.

ParameterDescription
forward_tracker_center_distanceHorizontal distance to the wheel center, in inches.
sideways_tracker_center_distanceVertical distance to the wheel center, in inches.

set_position

void set_position(point position, float orientation_deg,
float forward_tracker_position, float sideways_tracker_position);

Resets the position, including the tracking wheels. Position is field-centric, and 0 degrees points in the positive Y direction.

ParameterDescription
positionField-centric x/y position of the robot.
orientation_degField-centered, clockwise-positive orientation.
forward_tracker_positionCurrent forward sensor position, in inches.
sideways_tracker_positionCurrent sideways sensor position, in inches.

update_position

void update_position(float forward_tracker_position,
float sideways_tracker_position, float orientation_deg);

Runs one odometry update. Compares the input sensor readings against the stored values to update position and orientation_deg.

ParameterDescription
forward_tracker_positionCurrent forward sensor position, in inches.
sideways_tracker_positionCurrent sideways sensor position, in inches.
orientation_degField-centered, clockwise-positive orientation.

Public members

MemberDescription
positionCurrent field-centric x/y position.
orientation_degCurrent orientation in degrees.
forward_tracker_center_distanceConfigured forward tracker center distance.
sideways_tracker_center_distanceConfigured sideways tracker center distance.