Class CameraPoseFix
Built from last season's lessons (docs/from-last-season.md): the odometry must be right on its own; only the camera's correction is smoothed, never the wheel moves; each camera position is compared with where the robot was when the picture was taken (not now); old and repeated pictures are skipped; a big jump is refused; nothing is used while the robot moves fast. Every decision is said on a debug line: "used +1.2, -0.4 in" or "refused: moving".
The Limelight's field frame is the field's own; ours is from the drivers' wall (x right, y away,
heading 0 = facing away). turnDeg turns one into the other (a multiple of 90 for a square
field, found with the Camera Fix Check in Tune and check): our (x, y) = the Limelight's turned
turnDeg counterclockwise, and our heading = the Limelight's yaw + turnDeg - 90.
It never waits and never moves anything: the robot in five files calls record(long, double, double) every
loop and offer(double, double, long, long, int, double, double) for each new picture, and applies what it returns.
Docs: docs/modules/odometry.md, "Camera fix (alpha)"
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classWhat one picture did: the correction to add (0, 0 when refused) and the words for the debug line.static final classThe settings, all fromTunables.CameraFix. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplied(double dxIn, double dyIn) A correction was applied to the odometry: the recorded poses move with it, so a later picture (taken before it) does not count the same error again.last()The last picture's decision (for the debug line).doublelimelightYaw(double ourHeadingDeg) The heading to send the Limelight (its yaw, degrees) for our heading: ours - turnDeg + 90.offer(double llXIn, double llYIn, long pictureNanos, long nowNanos, int tags, double speedInPerSec, double turnDegPerSec) One NEW picture's position (the Limelight's frame, inches): the correction to add to the odometry, or why not.doubleourHeading(double limelightYawDeg) Our heading for a Limelight yaw: yaw + turnDeg - 90.voidrecord(long nanos, double xIn, double yIn) Every loop: the odometry's pose now (our frame, inches), so a picture can be compared with its own moment.static doublesuggestTurn(double ourHeadingDeg, double limelightYawDeg) The turnDeg that makes a Limelight yaw match our heading, to the nearest 90: for the Camera Fix Check (the robot standing still, its heading right).double[]toOurs(double llXIn, double llYIn) Our frame from the Limelight's: (x, y) turnedturnDegcounterclockwise.
-
Constructor Details
-
CameraPoseFix
-
-
Method Details
-
record
public void record(long nanos, double xIn, double yIn) Every loop: the odometry's pose now (our frame, inches), so a picture can be compared with its own moment. -
toOurs
public double[] toOurs(double llXIn, double llYIn) Our frame from the Limelight's: (x, y) turnedturnDegcounterclockwise.- Returns:
- {x, y} in inches
-
limelightYaw
public double limelightYaw(double ourHeadingDeg) The heading to send the Limelight (its yaw, degrees) for our heading: ours - turnDeg + 90. -
ourHeading
public double ourHeading(double limelightYawDeg) Our heading for a Limelight yaw: yaw + turnDeg - 90. -
suggestTurn
public static double suggestTurn(double ourHeadingDeg, double limelightYawDeg) The turnDeg that makes a Limelight yaw match our heading, to the nearest 90: for the Camera Fix Check (the robot standing still, its heading right). -
offer
public CameraPoseFix.Result offer(double llXIn, double llYIn, long pictureNanos, long nowNanos, int tags, double speedInPerSec, double turnDegPerSec) One NEW picture's position (the Limelight's frame, inches): the correction to add to the odometry, or why not.- Parameters:
pictureNanos- when the picture was taken (System.nanoTime clock)nowNanos- nowtags- tags in the picturespeedInPerSec- the robot's speed nowturnDegPerSec- its turn rate now
-
applied
public void applied(double dxIn, double dyIn) A correction was applied to the odometry: the recorded poses move with it, so a later picture (taken before it) does not count the same error again. -
last
The last picture's decision (for the debug line).
-