Odometry Sensors
LouLib contains three different classes that represent sensors that can be used for odometry
Rotation Sensor
The OdomRotationSensor class is used to represent a odometry dead-wheel
with a VEX V5 rotation sensor.
Creating a rotation sensor
The constructor for OdomRotationSensor takes three arguments:
int portThe port that the sensor is plugged into
bool reversedWhether or not the direction of the sensor needs to be reversed
LouLib::Units::Length wheelDiamThe diameter of the tracking wheel
Adding a gear ratio
If the odometry dead-wheel contains gears between the sensor shaft and the
wheel shaft, the setGearRatio method is used to ensure the
OdomRotationSensor returns accurate values. This method takes two
arguments:
int wheelSideThe number of teeth on the gear attatched to the same shaft as the tracking wheel
int sensorSideThe number of teeth on the gear attatched to the same shaft as the rotation sensor.
Motor Sensor
The OdomMotorSensor class is used to represent a drive wheel being
used as an odometry tracking wheel.
Creating a motor sensor
The constructor for OdomMotorSensor takes four arguments:
int motorPortThe port the motor is plugged into
pros::motor_gearset_e_t gearsetThe pros gearset of the motor
bool motorReversedWhether or not the direction of the motor needs to be reversed
LouLib::Units::Length wheelDiamThe diameter of the tracking wheel
Adding a gear ratio
If the drive contains gears between the motor shaft and the wheel shaft, the
setGearRatio method is used to ensure the OdomMotorSensor
returns accurate values. This method takes two arguments:
int wheelSideThe number of teeth on the gear attatched to the same shaft as the wheel
int sensorSideThe number of teeth on the gear attatched to the same shaft as the motor.
IMU Sensor
The OdomIMUSensor class is used to represent a VEX V5 rotation sensor
being used as a gyroscope for odometry heading.
Creating an IMU sensor
The constructor for OdomIMUSensor takes two arguments:
int portThe port the sensor is plugged into
double scale(optional)Sometimes VEX IMU sensors will return heading values that aren’t accurate, but can be made accurate by multiplying the output of the sensor by a scalar. This
scaleargument is used to provide the scalar for the IMU sensor being used. If noscaleis provided, it will default to 1 (the default IMU readings).