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

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.

Java
import com.tempo.logging.TempoLogging;

TempoLogging.everything("Tempo", sink)
    .except(TempoLogging.TIMING)
    .warnings(warning -> System.out.println(warning.message()))
    .apply();
Python
from tempo.logging import TempoLogging

TempoLogging.everything("Tempo", sink) \
    .except_(TempoLogging.TIMING) \
    .warnings(lambda warning: print(warning.message)) \
    .apply()
C++
#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();
JavaPythonC++Effect
pose(consumer) and the other itemspose(consumer), snake_casepose(consumer), snake_caseStarts 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

ItemValueArrivesKeys under the prefix
posePose2d, the pose getter’s answerEvery loop a route runsPose
plannedPosePose2dEvery loop a leg drivesPlannedPose
pathPose2d[], 250 posesFirst loop and each plan changePath
targetPose2d, the current leg’s targetEvery loop a leg is currentTarget
errorTransform2d, plannedPose.minus(pose)Every loop a leg drivesError/X, Error/Y (m), Error/Rotation (rad)
speedsChassisSpeeds, robot-relative, commandedEvery loop a route runsSpeeds/Vx, Speeds/Vy (m/s), Speeds/Omega (rad/s)
plannedSpeedsChassisSpeeds, robot-relative (the planned velocity rotated by the measured heading), zero while the route holds the robot at restEvery loop a route runs, except while an arriveWith command drivesPlannedSpeeds/Vx, /Vy, /Omega
replansTempoReplanEach replan’s endReplans/Count, /Leg, /Reason, /Installed, /TrackingError (m)
connectsTempoConnectEach connecting driveConnects/Count, /Step, /From, /To
giveUpsTempoGiveUpEach leg that gives upGiveUps/Count, /Leg, /Cause, /Pose
commandsTempoCommandEventEach command the route startsCommands/Count, /Name, /Leg
rotationEventsTempoRotationEventEach aim that takes the headingRotationEvents/Count, /Kind, /Leg, /Index, /Heading (rad)
arrivalsTempoArrivalEach leg’s endArrivals/Count, /Leg, /Reached, /TranslationError (m), /RotationError (rad)
warningsTempoWarningEach warning the route printsWarnings/Count, /Code, /Message
stateTempoStateEach change of auto, step, waypoint or phaseState/Auto, /Step, /Waypoint, /Phase
zonesTempoZone[]Each leg changeZones/Count, Zones/Names (kind:name, comma-joined), Zones/0, Zones/1, …
timingTempoTimingEvery loop a route runsTiming/CoreTick, /RouteTick (s), /PlansQueued, /HeldForPlan (s), /DroppedEvents
prePlanTempoPrePlanEach change in the selected auto’s pre-planning while disabledPrePlan/Auto, /Ready, /PlansReady, /PlansTotal
calibrationTempoCalibrationResultEach calibration routine’s end, and the run’s endCalibration/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++)ValuePython sink receives
pose(key, value)Pose2dPose2d
poses(key, value)Pose2d[] (std::vector in C++)list of Pose2d
number(key, value)doublefloat
text(key, value)Stringstr
flag(key, value)booleanbool

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).

RecordFields
TempoReplanleg, reason (offPath, behindSchedule, relocalized, fullRoute, crossing), installed, trackingErrorMeters
TempoConnectstep, from, to (Python from_pose, to_pose)
TempoGiveUpleg, cause (timeout, noRoute, planStuck, stalled, crossing), pose (null when unknown)
TempoCommandEventname, leg
TempoRotationEventleg, kind (aim), index, heading
TempoArrivalleg, reached, translationErrorMeters, rotationErrorRadians (NaN without an end heading)
TempoWarningcode (narrowTurn, planWait, legGaveUp, workerFault, junctions, coast, arrival, speedDeficit, crossingFailed, poseReset, bias, rejoin), message
TempoStateauto, step, waypoint, phase
TempoZonekind (obstacle, avoid, custom, keepIn, terrain), name, outline
TempoTimingcoreTickSeconds, routeTickSeconds, plansQueued, heldForPlanSeconds, droppedEvents
TempoPrePlanauto, ready, plansReady, plansTotal
TempoCalibrationResultroutine, 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.

esc

Loading search...