Skip to content
Tempo on GitHub (opens in a new tab)

3.25 Inspect a running auto

A route reports its state through logging items in every language.

In Java, a route built with Composer also has a RouteHandle that robot code can ask directly.

Queries

route.handle() returns the route’s RouteHandle. When the route runs more than once, the handle reports the latest run. It’s safe to call before the first run and after the last one.

CallReturns
started()true once the route has started a run
phase()one of the phases; NOT_STARTED before the first run
wedged()true while the current leg is stalled
replans()replans so far
replanFailed()true once a replan has failed during the run
skippedSegments(), skippedSegmentIndices()how many legs (a segment is a leg) had no route, and which ones, counting from 0
missedSegments(), missedSegmentIndices()how many legs were missed, and which ones: missed arrivals, which end farther than twice the tolerance from the waypoint, and legs that gave up or stalled short of it
droveEveryLeg()the route ran and no leg was skipped
arrivedEveryLeg()the route ran and no leg was skipped or missed
progress(nowS)leg(), the current leg counting from 0; of(), the number of legs; elapsedS(), the seconds since the auto started (the Setlist’s start when the route runs inside one). Zeros before the first run
expectedPose(nowS)the pose the route plans for the robot at that time, or null when the route isn’t driving

progress(nowS) and expectedPose(nowS) take the time from WPILib’s Timer.getTimestamp():

Java
double now = Timer.getTimestamp();
int leg = route.handle().progress(now).leg();
Pose2d expected = route.handle().expectedPose(now);

droveEveryLeg() and arrivedEveryLeg() only count the legs driven so far, so read them after the command finishes on its own. Don’t use phase() to tell how the route ended, because it can read CANCELLED after a normal finish too.

A leg that settled within twice its tolerance counts as arrived, and so does a leg that endWhen ended short of its waypoint.

wedged() becomes true when the robot is commanded to move but isn’t getting anywhere (Stalls), when a terrain crossing fails, or when the robot has stopped after a failed replan and has no path 0.75 s later. It stays true for the rest of the leg and is false again when the next leg starts.

Python and C++ have no call that returns the state of a scheduled route. Use the logging items below.

Logging the route’s state

These logging items carry the same state in every language. Legs count from 0 here, and from 1 in Tempo’s console lines.

To seeItemFields
The current leg and its phasestatewaypoint, phase
A leg that was skipped, stalled or gave upgiveUpsleg, cause (noRoute, stalled, timeout, crossing, planStuck)
Whether each leg ended inside its translation tolerancearrivalsleg, reached
Each replanreplansleg, reason
Where the plan expects the robot, and how far off it isplannedPose, error

This example puts the phase, the current leg, the last give-up and the last arrival on SmartDashboard. Add it once, after Tempo.configure(...). If your robot already has a TempoLogging chain, add these calls to it, because each apply() replaces the one before (Log Tempo state).

Java
import com.tempo.logging.TempoLogging;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

TempoLogging.state(state -> {
        SmartDashboard.putString("Auto/Phase", state.phase().toString());
        SmartDashboard.putNumber("Auto/Leg", state.waypoint());
    })
    .giveUps(giveUp -> SmartDashboard.putString("Auto/GiveUp",
        "leg " + giveUp.leg() + " " + giveUp.cause()))
    .arrivals(arrival -> SmartDashboard.putBoolean("Auto/Reached", arrival.reached()))
    .apply();
Python
from tempo.logging import TempoLogging
from wpilib import SmartDashboard

def log_state(state):
    SmartDashboard.putString("Auto/Phase", state.phase.name)
    SmartDashboard.putNumber("Auto/Leg", state.waypoint)

TempoLogging.state(log_state) \
    .give_ups(lambda give_up: SmartDashboard.putString(
        "Auto/GiveUp", f"leg {give_up.leg} {give_up.cause.value}")) \
    .arrivals(lambda arrival: SmartDashboard.putBoolean("Auto/Reached", arrival.reached)) \
    .apply()
C++
#include <string>

#include <frc/smartdashboard/SmartDashboard.h>
#include <tempo/wpi/TempoLogging.h>

tempo::wpi::TempoLogging::state([](const tempo::TempoState& state) {
    frc::SmartDashboard::PutString("Auto/Phase", std::string{tempo::to_string(state.phase)});
    frc::SmartDashboard::PutNumber("Auto/Leg", state.waypoint);
}).give_ups([](const tempo::TempoGiveUp& giveUp) {
    frc::SmartDashboard::PutString("Auto/GiveUp",
        "leg " + std::to_string(giveUp.leg) + " " + std::string{tempo::to_string(giveUp.cause)});
}).arrivals([](const tempo::TempoArrival& arrival) {
    frc::SmartDashboard::PutBoolean("Auto/Reached", arrival.reached);
}).apply();

The phase shows as DRIVING in Java and Python and as driving in C++.

reached is true for a leg that ended inside its translation tolerance with its required crossings driven. It’s false for a leg that gave up short of the waypoint, one endWhen ended early and one that settled just past its tolerance (Event records).

That makes reached stricter than arrivedEveryLeg(), which counts the last two as arrived.

esc

Loading search...