Stop guessing where your robot ended up. Odometry tracks your exact position on the field so your autonomous runs the same way every single time.
Your V5 drive motors have built-in encoders — they count how many times they spin. So why isn't that enough?
How many tracking wheels you need depends on what you want to measure:
| Sensor | Connection | Accuracy | Best For |
|---|---|---|---|
| VEX V5 Rotation Sensor | Smart Port (3-wire cable) | ★★★★★ Excellent | Primary choice — high resolution, easy to use, works great with EZ Template |
| Optical Shaft Encoder (3-wire) | ADI Port (A–H) | ★★★★ Good | Budget option — slightly lower resolution, still reliable for competition |
| IMU (Inertial Sensor) | Smart Port | ★★★★★ Excellent | Heading only — pairs with any tracking wheel setup. Almost required. |
| Distance Sensor | Smart Port | ★★★★ Good | Position correction against field walls — used alongside tracking wheels, not instead of them |
Plugs into any Smart Port (1–21) using a standard V5 3-wire smart cable. Gives you high-resolution angle data (0.088° resolution).
Two-wire sensor that plugs into ADI ports (A–H) using two adjacent ports. Lower resolution than rotation sensor but still reliable.
| Feature | PID Only (no odom) | With Odometry |
|---|---|---|
| Movements | Drive X inches, turn Y degrees | Go to coordinate (X, Y) |
| After a bump | Robot is lost — path continues wrong | Robot knows it moved, adjusts next move |
| Path planning | Sequential — each move is independent | Waypoint-based — robot finds its own path |
| Setup complexity | Simple | Moderate — needs tracking wheels mounted |
Odometry was added in EZ Template 3.x. Make sure you're on the latest version:
Tell EZ Template which sensors are your tracking wheels. This replaces or supplements the drive motor encoders:
Now instead of only using distance-based movements, you can drive directly to field coordinates:
{x, y, heading}. The robot automatically calculates the turn and drive needed to reach that point from wherever it currently is. This is the power of odometry — you plan a path, not a sequence of blind movements.In EZ Template, 0° means facing your starting direction. Positive degrees turn clockwise when viewed from above:
pid_odom_set() call. String them together and the robot will navigate smoothly between all of them.Different autonomous routines start from different positions on the field. Always set the starting pose at the beginning of each auton function:
Drive toward the wall, read the distance, calculate where you must be, and update the odometry pose:
You can also correct position partway through an autonomous routine — for example, after driving to a wall to drop a game element:
Before running any autonomous, do this test to confirm odom is reading correctly:
opcontrol(), print the robot's current pose every 100ms:X: 0.0 Y: 0.0 H: 0.0 in the terminal.The offset value in your tracking wheel declaration is how far the wheel is from the robot's center of rotation. Getting this right is critical for accurate turning:
| Symptom | Likely Cause | Fix |
|---|---|---|
| Y reads negative when pushing forward | Tracking wheel mounted backwards | Add true as last param in sensor declaration to reverse it |
| Position jumps or stutters | Tracking wheel losing contact with floor | Check spring tension — wheel must press firmly. Tighten mount. |
| X/Y drifts a lot during turns | Wrong offset value | Do the 5-rotation test and recalculate offset |
| Heading drifts over time | IMU not calibrated or disturbed | Ensure imu_calibrate() completes fully in initialize(). Don't move robot during calibration (~3 sec). |
| Odom accurate at first, wrong after 15 sec | Wheel slipping under load during turns | Move tracking wheel closer to center of robot or increase spring pressure |
| Robot doesn't reach coordinate target | Exit conditions too strict or odom PID not tuned | Tune pid_odom_constants_set() — similar to regular drive PID tuning |
Coordinate-based movements use their own PID constants separate from regular drive PID: