Software · Localization
Drive a swerve robot and watch AprilTag cameras fix the drift in its wheel odometry.
Click the field, then holdHold W A S D to drive and Q E to turn.
σ (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.
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.
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.
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.
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.
| Camera | Tags | Dist | Result |
|---|
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.
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.
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.