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.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 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).
    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).
    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 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 Odometry
    A goBILDA Pinpoint (I2C port), with goBILDA 4-bar pods unless you say otherwise.
    boolean
    True if the Pinpoint pods are written with podsFromEdgesMm(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.
    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.
    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 Odometry
    threeWheels(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 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 center) 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 center the forward-measuring pod is (right = negative); yPodForwardMm: how far FORWARD of the center the sideways-measuring pod is (back = negative).
    • robotSizeMm

      public Odometry 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). podsFromEdgesMm(double, double) and mountFromEdgesMm(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

      public Odometry podsFromEdgesMm(double forwardPodFromLeftMm, double sidewaysPodFromFrontMm)
      Pinpoint: where the pods sit, measured from the robot's EDGES (easier than from the center). Also write robotSizeMm(double, double); the library works out the center numbers of offsetsMm(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 edge
      sidewaysPodFromFrontMm - the sideways-measuring (Y) pod's wheel, mm from the robot's FRONT edge
      Returns:
      this odometry
    • mountFromEdgesMm

      public Odometry 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. Also write robotSizeMm(double, double); the library works out the numbers of mountIn(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 edge
      fromLeftMm - the sensor's middle, mm from the robot's LEFT edge
      headingDeg - the direction of its arrow, counterclockwise degrees (0 = forward)
      Returns:
      this odometry
    • 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 center, 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 center the forward-measuring pod is, inches (right = negative).
    • perpForwardIn

      public Odometry perpForwardIn(double inches)
      Dead wheels: how far FORWARD of the center 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.
    • podsFromEdges

      public boolean podsFromEdges()
      True if the Pinpoint pods are written with podsFromEdgesMm(double, double) (for the Odometry Tuner's advice).
    • 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(...).