Class PoseTracker
java.lang.Object
com.crossbotics.ftchelper.odometry.PoseTracker
- All Implemented Interfaces:
Subsystem
- Direct Known Subclasses:
DeadWheelOdometry,OtosOdometry,PinpointOdometry
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds this part's lines to the telemetry.final booleanTrue oncesetPose(com.crossbotics.ftchelper.util.FieldPose)was called: autonomous's start spot, the pose autonomous left for TeleOp, or your ownsetPose.abstract booleanisReady()True when the device works and gives a pose (not calibrating, no fault).abstract Stringkind()What kind it is, e.g.name()The name shown in telemetry and in the hardware check.final FieldPosepose()This loop's pose (a copy: changing it does not move the robot).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}.final voidsetHeading(double headingDeg) Makes the way the robot faces now this heading, keeping x and y (TeleOp's "forward = away from you now").final voidSays "the robot is here now".final doubleInches per second (how fast the robot moves).abstract Stringstatus()"ready", "calibrating", "Y pod not found"...final doubleDegrees per second (how fast it turns, counterclockwise +).final voidSays "the pose is not known any more" (isPoseSet()becomes false), keeping the numbers.final voidupdate()Reads the device once and works out the new pose.final voiduseClock(LongSupplier nanos) Uses this clock instead ofSystem.nanoTime()for the dead-wheel speed (tests: a pretend clock).final doubleThe robot's speed toward +x (to the RIGHT, seen from your drivers' wall), inches per second.final doubleThe robot's speed toward +y (AWAY from your drivers' wall), inches per second.protected abstract voidwrite(double xIn, double yIn, double headingDeg) Sets the device's pose in its own frame (X forward in, Y left in, heading CCW deg).
-
Constructor Details
-
PoseTracker
-
-
Method Details
-
update
public final void update()Reads the device once and works out the new pose. Called once per loop for you. -
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. WithvelocityY()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. SeevelocityX(). -
useClock
Uses this clock instead ofSystem.nanoTime()for the dead-wheel speed (tests: a pretend clock). Nanoseconds. -
setPose
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 oncesetPose(com.crossbotics.ftchelper.util.FieldPose)was called: autonomous's start spot, the pose autonomous left for TeleOp, or your ownsetPose. 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
"ready", "calibrating", "Y pod not found"... for the Driver Station. -
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
Description copied from interface:SubsystemThe name shown in telemetry and in the hardware check. -
addTelemetry
Description copied from interface:SubsystemAdds this part's lines to the telemetry. Uset.linefor drivers,t.debugfor programmers.- Specified by:
addTelemetryin interfaceSubsystem
-