Package com.crossbotics.ftchelper.robot
Class Odometry
java.lang.Object
com.crossbotics.ftchelper.robot.Odometry
The robot's odometry, one line in
Robot.java: what tells the robot where it is on the field.
odometry(Odometry.pinpoint("pinpoint").offsetsMm(-84, -168)); // goBILDA Pinpoint, 4-bar pods
odometry(Odometry.pinpoint("pinpoint").robotSizeMm(430, 400).podsFromEdgesMm(284, 383)); // the same, from the edges
odometry(Odometry.otos("otos").mountIn(0, -3, 0)); // SparkFun OTOS
odometry(Odometry.threeWheels("par_left", "par_right", "perp") // three dead wheels
.trackWidthIn(13.2).perpForwardIn(-6));
odometry(Odometry.twoWheels("par", "perp").parallelLeftIn(5).perpForwardIn(-6)); // two + the IMU
Then robot.pose() is the robot's place every loop, autonomous can drive to a field point
(s.driveTo(...)), and TeleOp starts where autonomous ended. Its numbers (the OTOS scales, and
checked) are in Tunables.Odometry. The Odometry Tuner finds the offsets.
Docs: docs/modules/odometry.md
-
Method Summary
Modifier and TypeMethodDescriptionstatic Odometrycustom(Function<Devices, PoseTracker> make) Your own pose source (e.g.booleanisReversed(String which) True if this pod ("x"/"y" for a Pinpoint, a port name for dead wheels) is inreversed(...).kindName()"pinpoint", "otos", "threeWheels" or "twoWheels" (for the Odometry Tuner).mountFromEdgesMm(double fromFrontMm, double fromLeftMm, double headingDeg) OTOS: where it sits, measured from the robot's EDGES (easier than from the center), and its arrow's direction.mountIn(double forwardIn, double leftIn, double headingDeg) OTOS: where it sits: inches forward of the center, inches left, and its arrow's direction (CCW deg).names()The configuration names, in the order written.offsetsMm(double xPodLeftMm, double yPodForwardMm) Pinpoint: where the pods sit, in mm (the Odometry Tuner measures them).static OdometryA SparkFun OTOS (I2C port).parallelLeftIn(double inches) Two dead wheels: how far LEFT of the center the forward-measuring pod is, inches (right = negative).perpForwardIn(double inches) Dead wheels: how far FORWARD of the center the sideways-measuring pod is, inches (back = negative).static OdometryA goBILDA Pinpoint (I2C port), with goBILDA 4-bar pods unless you say otherwise.booleanTrue if the Pinpoint pods are written withpodsFromEdgesMm(double, double)(for the Odometry Tuner's advice).podsFromEdgesMm(double forwardPodFromLeftMm, double sidewaysPodFromFrontMm) Pinpoint: where the pods sit, measured from the robot's EDGES (easier than from the center).goBILDA swingarm pods instead of 4-bar pods.doublePod encoder counts per mm.Pods that count the wrong way (the Odometry Tuner says which): for a Pinpoint "x" and/or "y"; for dead wheels the motor port names.robotSizeMm(double lengthMm, double widthMm) The robot's frame size, in mm: length front to back, width side to side (a tape across the frame, bumpers off).static OdometrythreeWheels(String leftParallel, String rightParallel, String perpendicular) Three dead wheels on encoder ports: two that measure forward (left and right of the center) and one that measures sideways.ticksPerMm(double ticks) Other pods: encoder counts per mm of wheel travel.trackWidthIn(double inches) Three dead wheels: the distance between the left and right forward-measuring pods, inches.static OdometryTwo dead wheels (one forward, one sideways) and the Control Hub's IMU for the heading.
-
Method Details
-
custom
Your own pose source (e.g. odometry fused with AprilTags, or another library's localizer), made at INIT from the robot's devices. It must use the library's frame (x right, y away, heading 0 = away, counterclockwise +). driveTo, robot.pose() and TeleOp use it like the built-in kinds. -
pinpoint
A goBILDA Pinpoint (I2C port), with goBILDA 4-bar pods unless you say otherwise. -
otos
A SparkFun OTOS (I2C port). -
threeWheels
Three dead wheels on encoder ports: two that measure forward (left and right of the center) and one that measures sideways. The names are the motor ports' configuration names. -
twoWheels
Two dead wheels (one forward, one sideways) and the Control Hub's IMU for the heading. -
offsetsMm
Pinpoint: where the pods sit, in mm (the Odometry Tuner measures them).xPodLeftMm: how far LEFT of the robot's center the forward-measuring pod is (right = negative);yPodForwardMm: how far FORWARD of the center the sideways-measuring pod is (back = negative). -
robotSizeMm
The robot's frame size, in mm: length front to back, width side to side (a tape across the frame, bumpers off).podsFromEdgesMm(double, double)andmountFromEdgesMm(double, double, double)need it: the library takes the middle of this box as the robot's center.- Parameters:
lengthMm- front edge to back edge, mm (more than 0)widthMm- left edge to right edge, mm (more than 0)- Returns:
- this odometry
-
podsFromEdgesMm
Pinpoint: where the pods sit, measured from the robot's EDGES (easier than from the center). Also writerobotSizeMm(double, double); the library works out the center numbers ofoffsetsMm(double, double). Measure to the middle of each pod's wheel. The Odometry Tuner then checks them and prints exact offsets.odometry(Odometry.pinpoint("pinpoint").robotSizeMm(430, 400).podsFromEdgesMm(284, 383)); // = offsetsMm(-84, -168): the forward pod 84 mm right of the center, the sideways pod 168 mm behind it- Parameters:
forwardPodFromLeftMm- the forward-measuring (X) pod's wheel, mm from the robot's LEFT edgesidewaysPodFromFrontMm- the sideways-measuring (Y) pod's wheel, mm from the robot's FRONT edge- Returns:
- this odometry
-
mountFromEdgesMm
OTOS: where it sits, measured from the robot's EDGES (easier than from the center), and its arrow's direction. Also writerobotSizeMm(double, double); the library works out the numbers ofmountIn(double, double, double). Measure to the middle of the sensor.odometry(Odometry.otos("otos").robotSizeMm(430, 400).mountFromEdgesMm(291, 200, 0)); // = mountIn(-3, 0, 0): 3 inches behind the center, in the middle side to side- Parameters:
fromFrontMm- the sensor's middle, mm from the robot's FRONT edgefromLeftMm- the sensor's middle, mm from the robot's LEFT edgeheadingDeg- the direction of its arrow, counterclockwise degrees (0 = forward)- Returns:
- this odometry
-
podsSwingarm
goBILDA swingarm pods instead of 4-bar pods. -
ticksPerMm
Other pods: encoder counts per mm of wheel travel. -
reversed
Pods that count the wrong way (the Odometry Tuner says which): for a Pinpoint "x" and/or "y"; for dead wheels the motor port names. -
mountIn
OTOS: where it sits: inches forward of the center, inches left, and its arrow's direction (CCW deg). -
trackWidthIn
Three dead wheels: the distance between the left and right forward-measuring pods, inches. -
parallelLeftIn
Two dead wheels: how far LEFT of the center the forward-measuring pod is, inches (right = negative). -
perpForwardIn
Dead wheels: how far FORWARD of the center the sideways-measuring pod is, inches (back = negative). -
kindName
"pinpoint", "otos", "threeWheels" or "twoWheels" (for the Odometry Tuner). -
names
The configuration names, in the order written. -
podsFromEdges
public boolean podsFromEdges()True if the Pinpoint pods are written withpodsFromEdgesMm(double, double)(for the Odometry Tuner's advice). -
podTicksPerMm
public double podTicksPerMm()Pod encoder counts per mm. -
isReversed
True if this pod ("x"/"y" for a Pinpoint, a port name for dead wheels) is inreversed(...).
-