Class Odometry

java.lang.Object
com.crossbotics.ftchelper.robot.Odometry

public final class Odometry extends Object
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.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 Type
    Method
    Description
    static Odometry
    Your own pose source (e.g.
    boolean
    True if this pod ("x"/"y" for a Pinpoint, a port name for dead wheels) is in reversed(...).
    "pinpoint", "otos", "threeWheels" or "twoWheels" (for the Odometry Tuner).
    mountIn(double forwardIn, double leftIn, double headingDeg)
    OTOS: where it sits: inches forward of the centre, inches left, and its arrow's direction (CCW deg).
    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 Odometry
    otos(String name)
    A SparkFun OTOS (I2C port).
    parallelLeftIn(double inches)
    Two dead wheels: how far LEFT of the centre the forward-measuring pod is, inches (right = negative).
    perpForwardIn(double inches)
    Dead wheels: how far FORWARD of the centre the sideways-measuring pod is, inches (back = negative).
    static Odometry
    A goBILDA Pinpoint (I2C port), with goBILDA 4-bar pods unless you say otherwise.
    goBILDA swingarm pods instead of 4-bar pods.
    double
    Pod encoder counts per mm.
    reversed(String... which)
    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.
    static Odometry
    threeWheels(String leftParallel, String rightParallel, String perpendicular)
    Three dead wheels on encoder ports: two that measure forward (left and right of the centre) 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 Odometry
    twoWheels(String parallel, String perpendicular)
    Two dead wheels (one forward, one sideways) and the Control Hub's IMU for the heading.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • custom

      public static Odometry custom(Function<Devices,PoseTracker> make)
      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

      public static Odometry pinpoint(String name)
      A goBILDA Pinpoint (I2C port), with goBILDA 4-bar pods unless you say otherwise.
    • otos

      public static Odometry otos(String name)
      A SparkFun OTOS (I2C port).
    • threeWheels

      public static Odometry threeWheels(String leftParallel, String rightParallel, String perpendicular)
      Three dead wheels on encoder ports: two that measure forward (left and right of the centre) and one that measures sideways. The names are the motor ports' configuration names.
    • twoWheels

      public static Odometry twoWheels(String parallel, String perpendicular)
      Two dead wheels (one forward, one sideways) and the Control Hub's IMU for the heading.
    • offsetsMm

      public Odometry offsetsMm(double xPodLeftMm, double yPodForwardMm)
      Pinpoint: where the pods sit, in mm (the Odometry Tuner measures them). xPodLeftMm: how far LEFT of the robot's centre the forward-measuring pod is (right = negative); yPodForwardMm: how far FORWARD of the centre the sideways-measuring pod is (back = negative).
    • podsSwingarm

      public Odometry podsSwingarm()
      goBILDA swingarm pods instead of 4-bar pods.
    • ticksPerMm

      public Odometry ticksPerMm(double ticks)
      Other pods: encoder counts per mm of wheel travel.
    • reversed

      public Odometry reversed(String... which)
      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

      public Odometry mountIn(double forwardIn, double leftIn, double headingDeg)
      OTOS: where it sits: inches forward of the centre, inches left, and its arrow's direction (CCW deg).
    • trackWidthIn

      public Odometry trackWidthIn(double inches)
      Three dead wheels: the distance between the left and right forward-measuring pods, inches.
    • parallelLeftIn

      public Odometry parallelLeftIn(double inches)
      Two dead wheels: how far LEFT of the centre the forward-measuring pod is, inches (right = negative).
    • perpForwardIn

      public Odometry perpForwardIn(double inches)
      Dead wheels: how far FORWARD of the centre the sideways-measuring pod is, inches (back = negative).
    • kindName

      public String kindName()
      "pinpoint", "otos", "threeWheels" or "twoWheels" (for the Odometry Tuner).
    • names

      public List<String> names()
      The configuration names, in the order written.
    • podTicksPerMm

      public double podTicksPerMm()
      Pod encoder counts per mm.
    • isReversed

      public boolean isReversed(String which)
      True if this pod ("x"/"y" for a Pinpoint, a port name for dead wheels) is in reversed(...).