Add odometry
A sensor that knows where the robot is on the field, so autonomous can drive to field points.
You need:
- A robot that drives, with its five files (The five files). The drive is
calibrated (
Tunables.Drive.calibrated = true, Drive Tuner). - For
driveTo: a mecanum drive. A tank robot can still use odometry forrobot.pose(). - On the robot, one of these three:
- a goBILDA Pinpoint and two pods (recommended). The Pinpoint goes on an I2C port. In the robot
configuration it is a “goBILDA® Pinpoint Odometry Computer”. Call it
pinpoint. - a SparkFun OTOS on an I2C port, 10 to 12 mm above the tiles. In the robot configuration it is a
“SparkFun OTOS”. Call it
otos. - dead wheels: three pods (or two and the Control Hub’s IMU), each in a motor port’s encoder connector.
- a goBILDA Pinpoint and two pods (recommended). The Pinpoint goes on an I2C port. In the robot
configuration it is a “goBILDA® Pinpoint Odometry Computer”. Call it
Which one to get, and how to mount and wire it: step 1.
1. What it is
Section titled “1. What it is”Odometry tells the robot its pose every loop: where it is (x, y) and which way it faces (heading).
- Pods are small free-turning wheels with encoders. Springs press them onto the tiles. One rolls forward and back (the X pod), one rolls sideways (the Y pod).
- Field numbers are inches, seen from your own drivers’ wall, whatever your alliance. x = inches right of the center line. y = inches away from your wall (negative = your half). Heading 0 = facing away from you, and a turn to the left is +. See the field numbers.
- It must know where its pods sit. When the robot turns in place, a pod away from the turn point rolls too. The library takes that roll away.
- You must check it before it drives.
driveTosteps do nothing on the robot untilTunables.Odometry.checked = true. Why: a pod that counts the wrong way would send the robot the wrong way at speed.
With odometry, driveTo goes to a field point and ends on it, even after a bump or a wheel slip. TeleOp
starts where autonomous ended.
Why odometry
Section titled “Why odometry”The drive wheels slip: they spin when another robot pushes yours, and they skid when the robot speeds up.
After a bump, a drive by distance (forward(...)) is off, and every later step is off too. The robot does
not know it.
The pods carry no weight and drive nothing, so they do not slip. They only roll and count. The robot adds up every small move, many times a second. So it knows its real pose.
Why not AprilTags in BIOBUZZ: the tags are on the HIVE cells, and the cells move. A tag tells you where you are compared with the tag, not with the field. So in BIOBUZZ, odometry says where the robot is, and the camera is for aiming.
Which one to get
Section titled “Which one to get”| Choice | What it is | Parts and price (checked 2026-10-21) |
|---|---|---|
| goBILDA Pinpoint + 2 pods (recommended) | a small odometry computer with its own IMU. Two pods plug into it, and it plugs into an I2C port | Pinpoint Odometry Computer V2, goBILDA 3110-0002-0002, $79.99. Two 4-bar odometry pods, goBILDA 3110-0001-0002, about $99.99 each (not checked on goBILDA’s page: check it before you order) |
| SparkFun OTOS | an optical sensor under the robot that watches the floor, like a computer mouse. No pods | SparkFun SEN-24904, $84.95 |
| Dead wheels | three pods (or two and the Control Hub’s IMU), each plugged into a motor port’s encoder connector. No extra computer | the pods only. They use three (or two) encoder ports |
- I2C port: the small 4-pin ports on the Control Hub (I2C 0 to 3). Sensors that send numbers, like the Pinpoint and the OTOS, plug in there.
- 4-bar and swingarm pods: goBILDA’s two pod designs. They give a different number of encoder counts
per mm. The library expects 4-bar pods. Swingarm pods need
.podsSwingarm()in the odometry line. - Why we recommend the Pinpoint: it does the math itself about 1500 times a second, and the robot reads the answer once per loop. So the loop speed does not change how good the pose is. It also uses no encoder ports.
Mount it, wire it, name it
Section titled “Mount it, wire it, name it”- Mount the two pods under the robot, with the springs pressing the wheels onto the tiles. One rolls forward and back (the X pod). One rolls sideways (the Y pod). They can sit anywhere: step 2 says how to give their places, and the tuner measures them.
- Mount the Pinpoint flat, anywhere on the robot.
- Plug the X pod into the Pinpoint’s X port, and the Y pod into its Y port. Why: the Pinpoint takes X as forward. With the pods swapped, the robot takes forward as sideways.
- Plug the Pinpoint into an I2C port on the Control Hub. Port 0 has the hub’s own IMU, so use port 1.
- Add it to the robot configuration on the Driver Hub: Configure Robot, edit your configuration,
Control Hub, the I2C bus you used (for example I2C Bus 1), Add. Choose the type goBILDA® Pinpoint
Odometry Computer and name it
pinpoint. Save, and restart the robot.
An OTOS goes on an I2C port the same way: type SparkFun OTOS, name otos. Mount it 10 to 12 mm above
the tiles. For dead wheels, plug each pod’s encoder cable into a motor port’s encoder connector. The pod’s
name is that motor port’s configuration name.
2. Add it to the five files
Section titled “2. Add it to the five files”Robot.java: one line
Section titled “Robot.java: one line”Where: Robot.java, in define(), right after the drive(...) line. Add
import com.crossbotics.ftchelper.robot.Odometry; at the top (Alt+Enter on the red name).
Use the line for your kind. Measure with a tape from the robot’s edges, with the bumpers off. The library works out the robot’s center from the size. The Odometry Tuner then measures the exact numbers.
A Pinpoint:
// After drive(...). The robot's length and width, then where each pod's wheel is, mm:// the forward pod from the LEFT edge, the sideways pod from the FRONT edge.odometry(Odometry.pinpoint("pinpoint").robotSizeMm(430, 400).podsFromEdgesMm(284, 383));| Number | What it is | Measure |
|---|---|---|
robotSizeMm(430, …) |
the robot’s length | front edge to back edge |
robotSizeMm(…, 400) |
the robot’s width | left edge to right edge |
podsFromEdgesMm(284, …) |
the X pod: the pod that rolls when the robot drives forward | LEFT edge to the middle of its wheel |
podsFromEdgesMm(…, 383) |
the Y pod: the pod that rolls when the robot drives sideways | FRONT edge to the middle of its wheel |
- Plug the X pod (forward) into the Pinpoint’s X port, and the Y pod (sideways) into its Y port.
- goBILDA swingarm pods need
.podsSwingarm()at the end of the line. The default is 4-bar pods.
An OTOS:
// The robot's length and width, then the OTOS's middle from the FRONT and LEFT edges (mm), and its turn.odometry(Odometry.otos("otos").robotSizeMm(430, 400).mountFromEdgesMm(126, 200, 0));| Number | What it is | Measure |
|---|---|---|
robotSizeMm(430, 400) |
length, then width | as for the Pinpoint |
mountFromEdgesMm(126, …, …) |
where the OTOS is, front to back | FRONT edge to the middle of the OTOS |
mountFromEdgesMm(…, 200, …) |
where the OTOS is, side to side | LEFT edge to the middle of the OTOS |
mountFromEdgesMm(…, …, 0) |
the way its arrow points | degrees, see below |
Careful: the OTOS line gives FRONT first, then LEFT. The Pinpoint line is the other way around.
The last number is the way the OTOS’s arrow points, in degrees (0 = forward, a turn to the left is +). The tuner cannot measure where an OTOS sits, so these tape numbers stay.
Dead wheels:
// The configuration names of the motor ports the pods plug into: left, right, sideways pod.// trackWidthIn: left pod to right pod. perpForwardIn: the sideways pod, 6 in BEHIND the center.odometry(Odometry.threeWheels("par_left", "par_right", "perp") .trackWidthIn(13.2).perpForwardIn(-6));| Number or name | What it is | Measure |
|---|---|---|
"par_left" |
the LEFT pod that rolls when the robot drives forward | its motor port’s configuration name |
"par_right" |
the RIGHT pod that rolls when the robot drives forward | its motor port’s configuration name |
"perp" |
the pod that rolls when the robot drives sideways | its motor port’s configuration name |
trackWidthIn(13.2) |
the distance between the two forward pods | the left pod’s wheel to the right pod’s wheel, inches |
perpForwardIn(-6) |
how far the sideways pod is ahead of the robot’s middle: + = ahead, − = behind | do not measure it from the middle (see below) |
A first perpForwardIn from the edges: (half the robot’s length) − (the sideways pod’s wheel from the
FRONT edge), in inches. Example: a robot 17 in long with the pod 14.5 in from the front: 8.5 − 14.5 = −6.
The Odometry Tuner then measures the exact number.
- Two pods and the IMU:
Odometry.twoWheels(parallel, perp)with.parallelLeftIn(...)and.perpForwardIn(...)(Odometry).
Dead wheels and the OTOS need the IMU in the drive line (.imu(...) in drive(...)). The tuner’s
Spin test uses it. The Pinpoint has its own.
Tunables.java: the check and the reset spot
Section titled “Tunables.java: the check and the reset spot”Where: Tunables.java, a new section. Its name is always Odometry.
public static class Odometry { // a fixed name: always Odometry public static boolean checked = false; // true after the Odometry Tuner's Loop test // "Set pose here" (TeleOp: hold gamepad 1 START 1 s on this spot), written for BLUE. public static double resetX = -56; // inches right of center, - = left public static double resetY = -61; // inches from center, - = our half public static double resetHeading = 0; // degrees, 0 = facing the field // RED: false = the same numbers from the red wall; true (or left out) = mirrored left-right. public static boolean mirrorForRed = false; // BIOBUZZ: false}checked: you set it totrueby hand, after the tuner’s Loop test passes (step 3).resetX,resetY,resetHeading: the reset spot. When autonomous did not run, TeleOp does not know where the robot is. Put the robot on this spot, let go of the sticks, and hold gamepad 1 START for 1 s. Here the spot is your left corner tile, facing the field.mirrorForRed = falseis for BIOBUZZ: its field is turned half a turn, so RED uses the same numbers from its own wall.
TeleOp starts where autonomous ended
Section titled “TeleOp starts where autonomous ended”You write nothing for this:
- When autonomous ends, its pose goes to TeleOp. TeleOp’s INIT starts the odometry there, if autonomous ran in the last 5 minutes. A Pinpoint still calibrates right after INIT: the library keeps the pose and gives it to the Pinpoint when it is ready.
- Field-centric “forward” comes from the odometry’s heading. Hold BACK to make “forward” the way the robot faces now. This is for the driver only: the pose does not change, so aiming at a field point stays right.
With no autonomous, or one stopped early, set the pose with the reset spot. Put the robot on it, let go
of the sticks, and hold gamepad 1 START (OPTIONS on a PlayStation gamepad) for 1 s. Do it in INIT if
you can. Gamepad 1 buzzes twice, and the Driver Station says Pose set: x -56, y -61 in, heading 0 (BLUE).
While the robot drives, it says Pose NOT set: stop first. START held with A or B pairs a gamepad, so it
never sets the pose. From code or an action: robot.resetPose() (the reset spot) or
robot.resetPose(x, y, heading). To move the button: lib.setPose(...)
(Move the library’s buttons).
One mirror setting for the whole robot. The autos’ start spots, the reset spot and the aim’s goal point
all use one answer to “is RED a mirror image of BLUE?”. The robot takes the first one it finds:
Tunables.Aim.mirrorForRed, then Tunables.Odometry.mirrorForRed, then the autonomous’s mirrorForRed(),
else true. Write it in Tunables.Odometry, so a TeleOp with no autonomous before it gets it right too.
INIT shows the one it uses: Reset spot for RED: ....
The autonomous ran with the wrong alliance: with the alliance switch in Controls.java
(lib.switchAlliance(g1.start, g1.back)), hold START, then BACK, for 1.5 s. On a mirrored field, the
library mirrors the pose too. On BIOBUZZ’s turned field it cannot: set the pose here again
(Switching the alliance in TeleOp).
Controls.java: show the pose
Section titled “Controls.java: show the pose”Where: Controls.java, inside buttons(...). The reset spot on START works with no line. To check
the odometry, show the pose on the Driver Station:
show("Where", () -> String.format(Locale.US, "x %.0f, y %.0f in, heading %.0f", robot.pose().x, robot.pose().y, robot.pose().headingDeg));For a second reset spot, or a reset from an action: How do I set the pose when autonomous did not run?.
A button that drives to a spot in TeleOp
Section titled “A button that drives to a spot in TeleOp”With odometry, a button can drive the robot to a field spot by itself, for example to park at the end. Any drive stick stops it at once, and the driver has the robot again. It needs a mecanum drive and a field map, so that it goes around the field parts.
Where: Robot.java, in define(), after the odometry(...) line: the field map.
// After odometry(...). The margin: half the robot's corner to corner size, plus some for drift.// Each box: two opposite corners, like driveTo's numbers. These are BIOBUZZ's two HIVE frames.fieldMap(FieldMap.margin(13) .keepOut("HIVE frame, near", -19.5, -24.8, 19.5, -15.4) .keepOut("HIVE frame, far", -19.5, 15.4, 19.5, 24.8));Where: Controls.java, inside buttons(...): the button, and a time when it starts by itself.
// route(...) makes the job. It starts when the button or the time says so.Runnable park = route("Park", -56, -36, 0, 0.8);g1.dpadLeft.tap(park).says("drive to the park spot (a drive stick stops it)");atSecondsLeft(10, park);route("Park", -56, -36, 0, 0.8): the spot’s x, y and heading (field numbers, as indriveTo), then the top power.atSecondsLeft(10, park): it starts with 10 s left. When a driver pushes a stick at that time, it waits until the sticks are let go (at most 5 s).- It drives only after the Drive Tuner and the Odometry Tuner (
calibratedandcheckedaretrue).
More: Keep-out boxes and routes.
Actions.java and autos: drive to field points
Section titled “Actions.java and autos: drive to field points”Where: a file in autos/, inside steps(...). It needs a mecanum drive.
// The start spot (x, y, heading) must be where the robot really stands: the pose starts there.s.start("Against our wall, in the left corner tile, facing the field", -56, -61, 0) .driveTo("To the goal", -30, -30, 45, 0.6) .parkWithSeconds(4) // The last number: "close enough", in inches (default 1). .driveTo("Park", -56, -36, 0, 0.7, 2.0);driveTo(label, x, y, heading, power): a place on the field, not a distance.- The numbers in
start(...)must be where the robot stands. The pose starts there.
An action can also use the pose. Where: Actions.java, one method per action.
/** Runs the intake while the robot is on our half of the field (y below 0). */public static Action intakeOnOurHalf(Robot r) { return Action.named("Intake on our half") .then(r.intake::in) .waitUntil("past the center line", () -> r.pose().y > 0, 10.0) .then(r.intake::stop);}To drive around field elements (routeTo), see
keep-out boxes and routes.
3. Find its numbers
Section titled “3. Find its numbers”The Odometry Tuner is in the Tune and check OpMode (how). You need a 48 in strip of tape on the floor, with a mark at its start.
- Forward 48 in: it says which way the X pod counts. For “counted BACKWARD”, add
.reversed("x")to the odometry line (dead wheels: that pod’s port name). - Left 24 in: it says which way the Y pod counts. For “counted RIGHT”, add
.reversed("y"). - Spin 3+ turns: it measures where the pods sit, and shows the line to change, for example
.offsetsMm(-84.2, -167.5). The 1st number is the X pod: mm LEFT of the robot’s middle (− = right). The 2nd is the Y pod: mm AHEAD of the middle (− = behind). With a Pinpoint, write.offsetsMm(...)in place of.robotSizeMm(...).podsFromEdgesMm(...). Dead wheels get.trackWidthIn(..).perpForwardIn(..). - Send the code again.
- Loop and back: drive away at least 24 in and come back onto the mark. Within 1 in and 2 degrees,
the screen says
Tunables.Odometry: checked = true. Write it inTunables.java.
An OTOS gets Tunables.Odometry: linearScalar = ... from the Forward test.
4. Check it, then tune it
Section titled “4. Check it, then tune it”Check it:
- Run your TeleOp. Push the robot by hand and watch the
Whereline. - Forward must make y go up. Left must make x go down. A turn to the left must make the heading go up.
- In an autonomous with a
driveTo, setTunables.Drive.maxPowerlow (0.4) for the first runs. Put the robot exactly on the start spot, and keep a hand on STOP. - In INIT, check for
Odometry: Pinpoint ready(or your kind). Run it. The robot must end within about 1 in of the point. - Run it again, and push the robot gently sideways while it drives. It must come back on course.
- Set
maxPowerback toDEFAULT.
Tune it with the Move Tuner. It makes moves stop where they should and
turns end on their heading. driveTo and routes use the same numbers (moveMinPower, slowDownIn,
turnMinPower). With an odometry line, the Move Tuner measures with the odometry, so it sees a skid.
Run its tests in order: Creep, Stops, Turns, Drift, then Move and turn on a mecanum. Put the
Tunables.Drive: lines it shows in Tunables.Drive.
To try a turn number without a new build, use Live tuning. The drive’s turn
numbers change at the next INIT. Then write the number in Tunables.Drive.
Fix a problem
Section titled “Fix a problem”| Problem | Why, and the fix |
|---|---|
skipped: Tunables.Odometry.checked is false in the report |
Run the tuner’s Loop test, then checked = true |
INIT stops: no GoBildaPinpointDriver named "pinpoint" |
The configuration name and type must match Robot.java |
Pinpoint: X pod not found: check its cable |
A pod cable is out of the Pinpoint |
Pinpoint: calibrating (keep the robot still) stays |
The robot moved in INIT. Keep it still, and INIT again |
| The pose goes the wrong way | A pod is reversed. Forward and Left tests, then .reversed("x") or ("y") |
| x and y look swapped | The X and Y pods are in each other’s ports |
| The pose drifts when the robot only turns | The offsets. Run the Spin test |
INIT stops: driveTo(...) needs a mecanum drive |
driveTo drives sideways. A tank robot uses turnTo and move |
| It drives to the mirror spot on RED | BIOBUZZ: mirrorForRed = false |
| It circles the point or stops just short | Run the Move Tuner |
The report says NO_ODOMETRY |
The odometry stopped during a driveTo. Check the pod and I2C cables |
OTOS: not answering |
The I2C cable, or the configuration name or type |
INIT stops: odometry .reversed("...") |
A name in .reversed(...) that is not a pod. A Pinpoint’s pods are "x" and "y" |
The tuner stops at INIT: needs the IMU |
Dead wheels or an OTOS: add .imu(...) to drive(...) |
| TeleOp’s field-centric is wrong after autonomous | The heading in s.start(...) is wrong |
No reset spot: add resetX, resetY, resetHeading to Tunables.Odometry |
The reset spot is missing in Tunables.Odometry |
| After “set pose here”, the pose is mirrored the wrong way on RED | BIOBUZZ: add mirrorForRed = false to Tunables.Odometry. INIT’s Reset spot for RED line shows which is used |
Pose NOT set: stop first |
The robot was driving (or aiming by itself). Stop, then hold START 1 s again |
More, for driveTo reports (STALLED, TIMED_OUT): Drive to points: problems.
Done when
Section titled “Done when”- Pushed by hand, the
Whereline goes the right way. - The Loop test passed, and
Tunables.Odometry.checked = true. - A
driveToends within about 1 in of its point.
Next: Make parts work together. For curved paths in autos: Add Pedro paths.
Look it up: Odometry: every setting, number and command.
Something wrong on this page? Tell us with a short GitHub form.