4.27 TempoLogging
TempoLogging sends an item to a consumer, a function you give for that one item, or
sends every item to a sink as keyed values under a prefix. The class is com.tempo.logging.TempoLogging in Java, tempo.logging.TempoLogging in Python and
tempo::wpi::TempoLogging (<tempo/wpi/TempoLogging.h>) in C++, which passes WPILib
types. The guide and ready-made sinks are in Log Tempo state.
import com.tempo.logging.TempoLogging;
TempoLogging.everything("Tempo", sink)
.except(TempoLogging.TIMING)
.warnings(warning -> System.out.println(warning.message()))
.apply();from tempo.logging import TempoLogging
TempoLogging.everything("Tempo", sink) \
.except_(TempoLogging.TIMING) \
.warnings(lambda warning: print(warning.message)) \
.apply()#include <cstdio>
#include <tempo/wpi/TempoLogging.h>
tempo::wpi::TempoLogging::everything("Tempo", sink)
.except({tempo::wpi::TempoLogging::Item::Timing})
.warnings([](const tempo::TempoWarning& warning) { std::puts(warning.message.c_str()); })
.apply();| Java | Python | C++ | Effect |
|---|---|---|---|
pose(consumer) and the other items | pose(consumer), snake_case | pose(consumer), snake_case | Starts or extends a builder. A second consumer for one item runs after the first |
everything(prefix, TempoLogSink) | everything(prefix, fn) | everything(prefix, std::shared_ptr<TempoLogSink>) | Every item to one sink. It starts the chain, so item consumers are added after it |
except(Item...) | except_(*items) | except({Item...}) | Leaves items out of the sink. Their consumers still run |
apply() | apply() | apply() | Replaces what was installed. Routes already running keep theirs |
off() | off() | off() | Routes that start afterward log nothing |
silence(TempoWarning.Code, boolean) | silence(code, silence) | silence(TempoWarning::Code, bool) | Stops or restarts the console lines of one warning code, at once |
silenceConsole(boolean) | silence_console(silence) | silence_console(bool) | Stops or restarts every [Tempo] console line except fatal ones, at once |
everything has to come first in a chain. Called after an item consumer, it doesn’t
compile in Java and C++ and raises TypeError in Python.
Tempo skips any item with no consumer. Consumers run on the robot loop, except the
calibration consumer, which runs on Tempo’s calibration worker thread. Treat the
values they receive as read-only, because arrays and speed objects can be shared with
the item’s other consumers.
Items
| Item | Value | Arrives | Keys under the prefix |
|---|---|---|---|
pose | Pose2d, the pose getter’s answer | Every loop a route runs | Pose |
plannedPose | Pose2d | Every loop a leg drives | PlannedPose |
path | Pose2d[], 250 poses | First loop and each plan change | Path |
target | Pose2d, the current leg’s target | Every loop a leg is current | Target |
error | Transform2d, plannedPose.minus(pose) | Every loop a leg drives | Error/X, Error/Y (m), Error/Rotation (rad) |
speeds | ChassisSpeeds, robot-relative, commanded | Every loop a route runs | Speeds/Vx, Speeds/Vy (m/s), Speeds/Omega (rad/s) |
plannedSpeeds | ChassisSpeeds, robot-relative (the planned velocity rotated by the measured heading), zero while the route holds the robot at rest | Every loop a route runs, except while an arriveWith command drives | PlannedSpeeds/Vx, /Vy, /Omega |
replans | TempoReplan | Each replan’s end | Replans/Count, /Leg, /Reason, /Installed, /TrackingError (m) |
connects | TempoConnect | Each connecting drive | Connects/Count, /Step, /From, /To |
giveUps | TempoGiveUp | Each leg that gives up | GiveUps/Count, /Leg, /Cause, /Pose |
commands | TempoCommandEvent | Each command the route starts | Commands/Count, /Name, /Leg |
rotationEvents | TempoRotationEvent | Each aim that takes the heading | RotationEvents/Count, /Kind, /Leg, /Index, /Heading (rad) |
arrivals | TempoArrival | Each leg’s end | Arrivals/Count, /Leg, /Reached, /TranslationError (m), /RotationError (rad) |
warnings | TempoWarning | Each warning the route prints | Warnings/Count, /Code, /Message |
state | TempoState | Each change of auto, step, waypoint or phase | State/Auto, /Step, /Waypoint, /Phase |
zones | TempoZone[] | Each leg change | Zones/Count, Zones/Names (kind:name, comma-joined), Zones/0, Zones/1, … |
timing | TempoTiming | Every loop a route runs | Timing/CoreTick, /RouteTick (s), /PlansQueued, /HeldForPlan (s), /DroppedEvents |
prePlan | TempoPrePlan | Each change in the selected auto’s pre-planning while disabled | PrePlan/Auto, /Ready, /PlansReady, /PlansTotal |
calibration | TempoCalibrationResult | Each calibration routine’s end, and the run’s end | Calibration/Routine, /MaxVelocity (m/s), /MaxAcceleration, /MaxDeceleration (m/s^2), /MaxAngularVelocity (rad/s), /MaxAngularAcceleration (rad/s^2), /Lag, /SteeringLag (s), /WheelRadius (m). NaN where not measured |
Item constants are TempoLogging.POSE through TempoLogging.CALIBRATION in Java and
Python, and Item::Pose through Item::Calibration in C++. Numbers are SI. An event item’s Count
key counts its events since apply(), and event keys hold their last value until the next
event. Zones/Count is the number of zones on the current leg and not an event count.
State/Phase is one of notStarted, preBlocking, driving, postBlocking,
waiting, done, cancelled and handedOff. A route that ends before it finishes,
through cancel(), Tempo.stop() or an interrupting command, reports cancelled.
Each loop hands items over in this order: pose, speeds, planned pose, target, error,
planned speeds, events as they happened, path, zones, state, timing. Tempo holds 64
events between loops, and any more are dropped and counted in droppedEvents. A
console line that can repeat every loop, like the dropped events notice, prints the
first time and then at most once every 5 seconds.
TempoLogSink
| Method (Java, C++) | Value | Python sink receives |
|---|---|---|
pose(key, value) | Pose2d | Pose2d |
poses(key, value) | Pose2d[] (std::vector in C++) | list of Pose2d |
number(key, value) | double | float |
text(key, value) | String | str |
flag(key, value) | boolean | bool |
Each call gets the full key, such as Tempo/Replans/Reason.
A Python sink is one callable sink(key, value). Test for bool before numbers,
since a bool is an int.
Event records
Java names are shown, and enum values are shown in their string spelling.
Python and C++ fields are snake_case, and the measured fields take a unit suffix
instead: tracking_error_m, translation_error_m, rotation_error_rad,
core_tick_s, route_tick_s and held_for_plan_s.
Python’s enum members are upper case and their values are those strings
(TempoReplan.Reason.OFF_PATH == "offPath").
C++ spells auto as auto_name and heading as heading_rad. Its poses and
outlines are read with tempo::wpi::from(event), tempo::wpi::to(event),
tempo::wpi::pose(event) and tempo::wpi::outline(zone).
| Record | Fields |
|---|---|
TempoReplan | leg, reason (offPath, behindSchedule, relocalized, fullRoute, crossing), installed, trackingErrorMeters |
TempoConnect | step, from, to (Python from_pose, to_pose) |
TempoGiveUp | leg, cause (timeout, noRoute, planStuck, stalled, crossing), pose (null when unknown) |
TempoCommandEvent | name, leg |
TempoRotationEvent | leg, kind (aim), index, heading |
TempoArrival | leg, reached, translationErrorMeters, rotationErrorRadians (NaN without an end heading) |
TempoWarning | code (narrowTurn, planWait, legGaveUp, workerFault, junctions, coast, arrival, speedDeficit, crossingFailed, poseReset, bias, rejoin), message |
TempoState | auto, step, waypoint, phase |
TempoZone | kind (obstacle, avoid, custom, keepIn, terrain), name, outline |
TempoTiming | coreTickSeconds, routeTickSeconds, plansQueued, heldForPlanSeconds, droppedEvents |
TempoPrePlan | auto, ready, plansReady, plansTotal |
TempoCalibrationResult | routine, finished, maxVelocityMps, maxAccelerationMps2, maxDecelerationMps2, maxAngularVelocityRadS, maxAngularAccelerationRadS2, lagS, steeringLagS, wheelRadiusM, acceleration, turning, capped, extrapolatedAboveMps, report, json. limits() gives a MeasuredConfigs (Calibrate the drivetrain) |
step counts the auto’s routes from 0, and waypoint and leg count a route’s legs from 0.
Console lines and .at(n) count from 1.
reached is true only when the robot ended within the leg’s translation tolerance with
its required crossings driven. It is false after a give-up, for a leg that endWhen
ended early, and for a leg that stopped past its tolerance but within twice the
tolerance (Missed arrivals). The route
counts the last two as arrived, so reached is stricter than Java’s
arrivedEveryLeg().
For a leg that hands into the next while still moving, reached and the translation
error are measured where the robot’s course passes the target.