Odometry Documentation
Overview
Odometry is the process of tracking the robot's position and orientation on the field using sensor data. Our robot uses a combination of tracking wheels and an IMU (Inertial Measurement Unit) to achieve precise position tracking through LemLib.
Hardware Configuration
Tracking Wheels
Our robot uses two tracking wheels for odometry:
// Horizontal tracking wheel (perpendicular to robot's forward direction)
lemlib::TrackingWheel horizontal_tracking_wheel(
&horizontal_sensor, // Rotation sensor on port 8
lemlib::Omniwheel::NEW_275, // 2.75" omni wheel
-5.75 // Distance from tracking center (inches)
);
// Vertical tracking wheel (parallel to robot's forward direction)
lemlib::TrackingWheel vertical_tracking_wheel(
&vertical_sensor, // Rotation sensor on port 9
lemlib::Omniwheel::NEW_275, // 2.75" omni wheel
-5.75 // Distance from tracking center (inches)
);
IMU (Inertial Measurement Unit)
pros::Imu imu(7); // IMU on port 7 for heading measurement
Sensor Configuration
lemlib::OdomSensors sensors(
&vertical_tracking_wheel, // Vertical tracking wheel 1
nullptr, // Vertical tracking wheel 2 (not used)
&horizontal_tracking_wheel, // Horizontal tracking wheel 1
nullptr, // Horizontal tracking wheel 2 (not used)
&imu // Inertial sensor
);
How Odometry Works
Basic Principle
- Tracking wheels measure linear movement in X and Y directions
- IMU provides accurate heading (rotation) measurement
- LemLib combines this data to calculate robot position
- Position is updated continuously in real-time
Coordinate System
- X-axis: Left/Right movement (positive = right)
- Y-axis: Forward/Backward movement (positive = forward)
- Theta: Robot heading in degrees (0° = facing forward)
Tracking Wheel Placement
Vertical Tracking Wheel
- Purpose: Measures forward/backward movement (Y-axis)
- Placement: Perpendicular to robot's main axis
- Offset: -5.75" from robot center
- Why offset matters: Accounts for wheel placement relative to robot's center of rotation
Horizontal Tracking Wheel
- Purpose: Measures left/right movement (X-axis)
- Placement: Parallel to robot's main axis
- Offset: -5.75" from robot center
- Critical for: Detecting sideways drift during turns
Calibration Process
Initial Calibration
void initialize() {
chassis.calibrate(); // Calibrates IMU and resets position to (0,0,0)
}
What Calibration Does
- IMU Calibration: Determines IMU bias and drift
- Position Reset: Sets current position as origin (0, 0, 0°)
- Sensor Zeroing: Resets all tracking wheel encoders
Calibration Best Practices
- Keep robot completely still during calibration
- Place robot on level surface
- Allow 2-3 seconds for calibration to complete
- Don't move robot until calibration finishes
Position Tracking Display
Our code displays real-time position on the brain screen:
pros::Task screen_task([&]() {
while (true) {
pros::lcd::print(0, "X: %f", chassis.getPose().x); // X position
pros::lcd::print(1, "Y: %f", chassis.getPose().y); // Y position
pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // Heading
pros::delay(20);
}
});
Accuracy Factors
Sources of Error
- Wheel Slippage: Tracking wheels slipping on field tiles
- Mechanical Play: Backlash in gears and mounting
- IMU Drift: Small errors accumulating over time
- Wheel Wear: Changes in effective wheel diameter
- Field Conditions: Debris, uneven tiles, or damage
Improving Accuracy
- Proper wheel tension: Ensure tracking wheels contact ground firmly
- Quality bearings: Reduce friction and play
- Rigid mounting: Minimize flex in tracking wheel assemblies
- Regular calibration: Recalibrate between matches
- Wheel maintenance: Keep tracking wheels clean and round
Common Issues and Troubleshooting
Position Drift
Symptoms: Robot position slowly drifts even when stationary Causes:
- IMU not properly calibrated
- Tracking wheels slipping
- Mechanical issues
Solutions:
- Recalibrate IMU
- Check tracking wheel contact with ground
- Verify sensor wiring
Incorrect Heading
Symptoms: Robot thinks it's facing different direction Causes:
- IMU mounting orientation
- IMU calibration issues
- Electromagnetic interference
Solutions:
- Ensure IMU is mounted flat and secure
- Calibrate away from motors and metal
- Check for loose connections
Inaccurate Distance Measurement
Symptoms: Robot reports wrong X/Y position Causes:
- Wrong wheel diameter in code
- Tracking wheel slippage
- Incorrect offset measurements
Solutions:
- Verify wheel diameter (should be 2.75")
- Measure and verify offset distances
- Check wheel mounting and tension
Testing and Validation
Recommended Tests
- Stationary Test: Leave robot still for 30 seconds, position should not drift
- Straight Line Test: Drive 48" forward, measure actual vs. reported distance
- Square Test: Drive in 24"×24" square, should return to start position
- Rotation Test: Spin 360°, heading should return to 0°
- Complex Path: Drive figure-8 pattern, check for cumulative error
Acceptable Tolerances
- Linear accuracy: ±1" after 48" movement
- Angular accuracy: ±2° after 360° rotation
- Drift rate: less than 0.1" per second when stationary
Integration with Motion Control
Odometry enables advanced autonomous features:
- Pure Pursuit: Follow curved paths smoothly
- Point-to-Point: Drive directly to field coordinates
- Path Following: Execute pre-planned routes
- Field-Relative Control: Move relative to field, not robot
Future Improvements
- Add sensor fusion with vision system
- Implement Kalman filtering for better accuracy
- Add wheel slip detection
- Create field position validation system
- Log odometry data for analysis
Last updated: 2025-08-25