4.31 TempoAuto
Each run of a Composer route goes through the phases on this page. A TempoAuto runs
them, but robot code doesn’t build one and no supported call returns one. Java robot
code reads a route’s status from the
RouteHandle that Composer.handle()
returns, and every language reads it through logging.
Phases
These are the phases Java’s RouteHandle.phase() returns. The state
logging item reports the same phases in every
language as State/Phase, spelled notStarted, preBlocking, driving, handedOff,
postBlocking, waiting, done and cancelled.
NOT_STARTED
| the route's command starts
v
PRE_BLOCKING runBefore commands run; robot stopped
| every runBefore command has finished
v
DRIVING following the trajectory
| the leg arrives, fails or ends on endWhen
|
| arriveWith legs only, at the arriveWith fraction or on arrival:
| HANDED_OFF the arriveWith command drives; Tempo commands nothing
| until that command ends, the leg's give-up time, or endWhen
v
POST_BLOCKING runAfter commands run; robot stopped
| every runAfter command has finished
v
WAITING an Arrival.pause(t), or the next leg waiting for its plan; robot stopped
| the pause ends or the plan is ready
v
next leg, or DONE when every leg is done (RouteHandle.phase() then reads CANCELLED)
CANCELLED from any phase when the run is canceled- A leg with no
runBeforestarts inDRIVING, and one with norunAfterand no pause skipsPOST_BLOCKINGandWAITING. - Progress and zone triggers fire only while driving, but match-time triggers also fire in blocking phases.
A leg ends once the robot is inside its arrival tolerance of the planned end, with the
waits listed under Missed arrivals, which also
covers a leg that ends outside the tolerance. Heading counts only on a leg with an end
heading, and a pose with a NaN coordinate never arrives. SimRun uses the same test.
RouteHandle.phase() reads CANCELLED after every run, including one that finished
normally. The logged State/Phase stays done after a clean finish and reads
cancelled only for a run ended early. On the handle, droveEveryLeg() says no leg
has been skipped so far, and arrivedEveryLeg() also says none has been missed, so
both stay true for a run interrupted partway.
Read them once State/Phase is done, or use the arrivals and giveUps logging
items. An arrival’s reached is
stricter than arrivedEveryLeg().
Each loop
The route’s command reads the pose and sends robot-relative ChassisSpeeds
(ChassisVelocities on 2027) every 20 ms loop. It sends zero speeds in PRE_BLOCKING,
POST_BLOCKING and WAITING. A robot still moving when a leg starts waiting for its
plan slows to a stop at the leg’s acceleration limit first. In HANDED_OFF Tempo sends
nothing and the arriveWith command drives.
What robot code can read while the route runs (a segment in a method name is a leg):
| Reading | Java route.handle() | Logging item |
|---|---|---|
| Phase | phase() | state |
| Current leg | progress(nowS) | state |
| Planned pose for this loop | expectedPose(nowS) | plannedPose |
| Driving but not progressing (Stalls) | wedged() | |
| Replans | replans(), replanFailed() | replans |
| Legs skipped or missed | skippedSegments(), missedSegments() | giveUps, arrivals |
nowS is WPILib’s Timer.getTimestamp(). progress returns the current leg, the leg count
and the seconds since the auto started. expectedPose returns the planned pose for that
time, or null when the route isn’t driving.
TempoCommand
TempoCommand (com.tempo.wpi, tempo.wpi, <tempo/wpi/TempoCommand.h>) is a public
command class, but its constructor needs a TempoAuto and robot code has no way to
build one. Use the WPILib Command that Composer.command() and Setlist.command()
return (tempo::wpi::command(route) and tempo::wpi::Setlist::command(setlist) in
C++). In Java that command isn’t a TempoCommand, so a cast fails.
Named poses
Pose (com.tempo.wpi, tempo.wpi, <tempo/wpi/Pose.h>) keeps named poses in
src/main/deploy/tempo-poses.json in Java and C++ and deploy/tempo-poses.json in
Python.
| Java | Python | C++ | Behavior |
|---|---|---|---|
Pose.at(x, y) | Pose.at(x, y) | Pose::At(x, y) | A pose in meters with heading 0. Chain heading(rad) or headingDeg(deg) (heading_deg in Python, Heading and HeadingDeg in C++) |
Pose.named(name) | Pose.named(name) | Pose::Named(name) | Looks up a pose. An unknown name throws, and the message lists the known names |
Pose.capture(name, pose) | Pose.capture(name, pose) | Pose::Capture(name, pose) | Saves a pose and prints [Tempo] captured pose ... |
Pose.captureCommand(poseSupplier, nameSupplier) | Pose.capture_command(pose_supplier, name_supplier) | Java and Python only. A command that captures when scheduled, including while disabled |
In simulation the file persists, but on the robot a capture lasts until the next deploy.