Class PoseTracker

java.lang.Object
com.crossbotics.ftchelper.odometry.PoseTracker
All Implemented Interfaces:
Subsystem
Direct Known Subclasses:
DeadWheelOdometry, OtosOdometry, PinpointOdometry

public abstract class PoseTracker extends Object implements Subsystem
Where the robot is on the field, from odometry: small wheels ("pods") or a sensor that measure how far the robot moved. One class for every kind: a goBILDA Pinpoint, a SparkFun OTOS, or three or two dead wheels on motor encoder ports.

The frame (the same as autonomous start spots, Steps.start): seen from your drivers' wall, x inches to the right, y inches away from you, heading 0 = facing away from you, counterclockwise positive. Where (0, 0) is: wherever you set it (setPose(com.crossbotics.ftchelper.util.FieldPose)); autonomous sets it from the start spot.

It is a Subsystem: update() runs once per loop, first, so every part reads this loop's pose. It never waits. Docs: docs/modules/odometry.md

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds this part's lines to the telemetry.
    final boolean
    True once setPose(com.crossbotics.ftchelper.util.FieldPose) was called: autonomous's start spot, the pose autonomous left for TeleOp, or your own setPose.
    abstract boolean
    True when the device works and gives a pose (not calibrating, no fault).
    abstract String
    What kind it is, e.g.
    The name shown in telemetry and in the hardware check.
    final FieldPose
    This loop's pose (a copy: changing it does not move the robot).
    protected abstract double[]
    The device's pose in its own frame: {X forward in, Y left in, heading CCW deg}, plus, if it knows, {vX in/s, vY in/s, turn deg/s}.
    final void
    setHeading(double headingDeg)
    Makes the way the robot faces now this heading, keeping x and y (TeleOp's "forward = away from you now").
    final void
    Says "the robot is here now".
    final double
    Inches per second (how fast the robot moves).
    abstract String
    "ready", "calibrating", "Y pod not found"...
    final double
    Degrees per second (how fast it turns, counterclockwise +).
    final void
    Says "the pose is not known any more" (isPoseSet() becomes false), keeping the numbers.
    final void
    Reads the device once and works out the new pose.
    final void
    Uses this clock instead of System.nanoTime() for the dead-wheel speed (tests: a pretend clock).
    final double
    The robot's speed toward +x (to the RIGHT, seen from your drivers' wall), inches per second.
    final double
    The robot's speed toward +y (AWAY from your drivers' wall), inches per second.
    protected abstract void
    write(double xIn, double yIn, double headingDeg)
    Sets the device's pose in its own frame (X forward in, Y left in, heading CCW deg).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.crossbotics.ftchelper.core.Subsystem

    stop
  • Constructor Details

    • PoseTracker

      protected PoseTracker(String name)
  • Method Details

    • update

      public final void update()
      Reads the device once and works out the new pose. Called once per loop for you.
      Specified by:
      update in interface Subsystem
    • pose

      public final FieldPose pose()
      This loop's pose (a copy: changing it does not move the robot).
    • speedInPerSec

      public final double speedInPerSec()
      Inches per second (how fast the robot moves). A Pinpoint or OTOS tells it; with dead wheels it is worked out from how far the robot moved between loops (smoothed).
    • turnDegPerSec

      public final double turnDegPerSec()
      Degrees per second (how fast it turns, counterclockwise +). From the device when it tells, otherwise worked out from the heading change between loops (smoothed).
    • velocityX

      public final double velocityX()
      The robot's speed toward +x (to the RIGHT, seen from your drivers' wall), inches per second. With velocityY() it says which way the robot moves over the field, whichever way it faces. From a Pinpoint or an OTOS directly; with dead wheels, from how far it moved between loops. Shooting on the move uses it (Tunables.Aim.shootOnMove, docs/modules/robot.md#aim).
    • velocityY

      public final double velocityY()
      The robot's speed toward +y (AWAY from your drivers' wall), inches per second. See velocityX().
    • useClock

      public final void useClock(LongSupplier nanos)
      Uses this clock instead of System.nanoTime() for the dead-wheel speed (tests: a pretend clock). Nanoseconds.
    • setPose

      public final void setPose(FieldPose p)
      Says "the robot is here now". Autonomous does this from its start spot; TeleOp from where autonomous ended. Our frame (see the class).
    • setHeading

      public final void setHeading(double headingDeg)
      Makes the way the robot faces now this heading, keeping x and y (TeleOp's "forward = away from you now"). It does NOT count as setting the pose (isPoseSet() stays as it was): x and y are still only as good as before.
    • isPoseSet

      public final boolean isPoseSet()
      True once setPose(com.crossbotics.ftchelper.util.FieldPose) was called: autonomous's start spot, the pose autonomous left for TeleOp, or your own setPose. False means the pose is only "where the robot was turned on = (0, 0)", which is NOT a place on the field: aiming by odometry stays off until then.
    • unsetPose

      public final void unsetPose()
      Says "the pose is not known any more" (isPoseSet() becomes false), keeping the numbers. Aiming by odometry then stays off until the pose is set again (setPose(com.crossbotics.ftchelper.util.FieldPose), TeleOp's "set pose here"). TeleOp does this when the alliance is switched on a field that is not mirrored: the pose from an autonomous run as the wrong alliance cannot be trusted. Never waits.
    • isReady

      public abstract boolean isReady()
      True when the device works and gives a pose (not calibrating, no fault).
    • status

      public abstract String status()
      "ready", "calibrating", "Y pod not found"... for the Driver Station.
    • kind

      public abstract String kind()
      What kind it is, e.g. "Pinpoint".
    • read

      protected abstract double[] read()
      The device's pose in its own frame: {X forward in, Y left in, heading CCW deg}, plus, if it knows, {vX in/s, vY in/s, turn deg/s}. Null if there is nothing new.
    • write

      protected abstract void write(double xIn, double yIn, double headingDeg)
      Sets the device's pose in its own frame (X forward in, Y left in, heading CCW deg).
    • name

      public String name()
      Description copied from interface: Subsystem
      The name shown in telemetry and in the hardware check.
      Specified by:
      name in interface Subsystem
    • addTelemetry

      public void addTelemetry(RobotTelemetry t)
      Description copied from interface: Subsystem
      Adds this part's lines to the telemetry. Use t.line for drivers, t.debug for programmers.
      Specified by:
      addTelemetry in interface Subsystem