Software · Localization

Pose Estimator Lab

Drive a swerve robot and watch AprilTag cameras fix the drift in its wheel odometry.

True robot Odometry Fused estimate ×Rejected Circle = σ Our alliance zone Focus tag
Step 1 of 8

Odometry error–
Fused error–
Within 0.06 m and 0.017 rad? Not yet
More numbers
True pose–
Odometry (smooth pose)–
Fused (field pose)–
Distance driven–
Speed–
Surface–
State–

Click the field, then holdHold W A S D to drive and Q E to turn.

Why?

σ (sigma) is how far off you expect a reading to be. Each reading pulls the estimate q ÷ (q + σ) of the way toward it. The 2026 robot uses σ 0.9 for x, y and heading, a 10% pull.

Why?

Spinning smears the picture. The 2026 code drops every reading while the gyro reads faster than 12.57 rad/s (720°/s). This robot only turns 4.7 rad/s, so that never happens here.

Why?

A one-tag solve can't always tell which way the tag is tilted, so it can flip. The zone is judged from the fused estimate, since the robot can't know the truth.

Why?

A bad solve often gets the heading badly wrong too. The 2026 code has this check, but set to 6.28 rad (2π), so it never fires.

Localization state
Why?

RobotContainer asks for SHOOTING_FOCUS while aiming and shooting, FULL otherwise. A reading that includes a ringed tag uses the focused σ. No tags are thrown away. See state machines.

More controls

Cameras

×1.0
Alliance

Driving and odometry

4.0
3.0
15
0.3

Filter

Ideas not in the 2026 code

Camera readings

Last 2 seconds
CameraTagsDistResult

Go deeper

How our cameras find the robot

Three global-shutter cameras face left, right and back. Left and right sit 0.29 m off the floor, the back one 0.54 m. All tilt up 0.17 rad (10°) and see about 1.35 rad (77°) side to side. Because they tilt up, a tag that is too close or too low drops out of view. The hub and trench walls block anything behind them.

An Nvidia Jetson finds AprilTags with a GPU detector at 60 frames a second per camera, solves the robot's pose, and sends it to the roboRIO with the time the picture was taken.

How the Kalman filter blends odometry and vision

Odometry adds up how far the wheels turned, with the gyro giving the heading. Worn treads, carpet seams, wheel scrub, bumps (a 0.29 rad slope) and pushing into walls make it drift. Another robot shoving ours slides the wheels sideways, so odometry never sees it.

The robot runs two estimators. The smooth pose only uses odometry. The field pose also takes camera readings through addVisionMeasurement(pose, timestamp, stdDevs). Each reading pulls it a fraction q ÷ (q + σ) of the way, the WPILib pose estimator's gain. With q 0.1 and σ 0.9 that is 10%. The Computer Vision lesson starts at σ 5.0, a 2% pull, and checks for 0.06 m and 0.017 rad.

The 2026 vision checks, in order
  1. Spin rate over 12.57 rad/s: drop the whole frame. The code compares the signed rate, so only counter-clockwise spins trip it. This lab checks both directions.
  2. Inside our alliance zone (x < 3.963 m, mirrored for red), fewer than 2 tags: skip.
  3. Pose outside the field walls: skip.
  4. Heading more than 6.28 rad from the estimate: skip. That never happens, so this check is off.
  5. Everything else gets σ 0.9, or the focused / not-focused σ in a focus state.
Why each reading is off

Expected error (1σ) = distance error × viewing-angle factor + motion blur + bump tilt. The robot never sees this number. The 2026 code gives every reading the same σ, so a blurry far reading counts as much as a sharp close one.

Error over time
Odometry onlyFused estimate
Things to try
  1. Turn the cameras off and spin with Q for a few turns. The fused heading error grows. Turn them on and it shrinks.
  2. Get shoved, then drive to a hub. How long until the badge says Yes again?
  3. Questions for next season: should σ grow with tag distance? Should the spin check use the absolute value? Should the heading check be on? What σ should the focus states use?
Read more in the docs