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

3.23 Log Tempo state

Tempo doesn’t log anything until you install a consumer with TempoLogging. A consumer is a function you write that receives one item, such as the robot pose, the planned path or a replan, and logs it with whichever logging library your robot uses.

Log a few items

This example logs the pose and path with AdvantageKit and prints warnings.

This example logs the pose’s x to SmartDashboard and prints warnings.

Java
import com.tempo.logging.TempoLogging;
import org.littletonrobotics.junction.Logger;

TempoLogging.pose(pose -> Logger.recordOutput("Tempo/Pose", pose))
    .path(path -> Logger.recordOutput("Tempo/Path", path))
    .warnings(warning -> System.out.println(warning.message()))
    .apply();
Python
from tempo.logging import TempoLogging
from wpilib import SmartDashboard

TempoLogging.pose(lambda pose: SmartDashboard.putNumber("Tempo/X", pose.X())) \
    .warnings(lambda warning: print(warning.message)) \
    .apply()
C++
#include <cstdio>

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

tempo::wpi::TempoLogging::pose([](const frc::Pose2d& pose) {
    frc::SmartDashboard::PutNumber("Tempo/X", pose.X().value());
}).warnings([](const tempo::TempoWarning& warning) {
    std::puts(warning.message.c_str());
}).apply();

Install consumers once, after Tempo.configure(...). apply() only affects routes that start after it, and each apply() replaces what an earlier one installed, so put every consumer in one chain. TempoLogging.off() turns logging off for routes that start afterward.

Quiet the console

Tempo prints its warnings to the console as [Tempo] lines. TempoLogging.silence stops the lines of one warning code, and silenceConsole (silence_console) stops nearly every [Tempo] line. Both take effect right away and last until you call them again with false. A silenced warning still reaches the warnings consumer and a sink.

Java
import com.tempo.logging.TempoLogging;
import com.tempo.logging.TempoWarning;

TempoLogging.silence(TempoWarning.Code.CROSSING_FAILED, true);   // no crossingFailed lines
TempoLogging.silenceConsole(true);                              // nearly every [Tempo] line
Python
from tempo.logging import TempoLogging, TempoWarning

TempoLogging.silence(TempoWarning.Code.CROSSING_FAILED, True)   # no crossingFailed lines
TempoLogging.silence_console(True)                              # nearly every [Tempo] line
C++
#include <tempo/wpi/TempoLogging.h>

tempo::wpi::TempoLogging::silence(tempo::TempoWarning::Code::CrossingFailed, true);
tempo::wpi::TempoLogging::silence_console(true);

The codes are listed under TempoWarning. These lines still print with the console silenced:

  • an error that ends a route or the auto
  • the workerFault warning (WORKER_FAULT in the Code enum, WorkerFault in C++)
  • the message Tempo prints at startup when the robot runs a WPILib or RobotPy version the Tempo build doesn’t support
  • the report a calibration prints when it ends

Log everything under one prefix

everything(prefix, sink) sends every item to one sink. The sink is your code that writes a value to the logging library under a key, and every key starts with the prefix. NetworkTablesSink in this example is one of the ready-made sinks below.

Java
TempoLogging.everything("Tempo", new NetworkTablesSink())
    .except(TempoLogging.TIMING)
    .apply();
Python
TempoLogging.everything("Tempo", network_tables_sink) \
    .except_(TempoLogging.TIMING) \
    .apply()
C++
tempo::wpi::TempoLogging::everything("Tempo", std::make_shared<NetworkTablesSink>())
    .except({tempo::wpi::TempoLogging::Item::Timing})
    .apply();

except(...) leaves items out of the sink. Consumers for single items go after everything(...) in the same chain.

It’s except_ in Python because except is a keyword.

A sink implements TempoLogSink, which has one method for each kind of value: pose, poses, number, text and flag. Each one is given the full key.

In Python a sink is a single callable that takes (key, value). The value is a WPILib Pose2d, a list of Pose2d, a float, a str or a bool.

The items, their keys and the record fields are in TempoLogging. Event items, such as replans and arrivals, only write their keys when an event happens, and the keys keep their last value until the next one. An event item also writes a Count key that goes up by one per event.

Python and C++ spell the item methods in snake case (planned_pose, give_ups). Record fields there are snake case, with a unit suffix on measured values (tracking_error_m).

Get a log file for AdvantageScope

Tempo doesn’t write a log file. If your sink publishes to NetworkTables, like the one below, call DataLogManager.start() once at startup and it records NetworkTables into a .wpilog. On a roboRIO that file goes on a USB stick if one is plugged in, and in /home/lvuser/logs if not.

AdvantageScope’s Download Logs reads /U/logs (the USB stick) unless its preferences name another folder. Without a USB stick, set the roboRIO log folder in AdvantageScope’s preferences to /home/lvuser/logs, or plug one in. The Tempo keys are under NT:/ plus the prefix, such as NT:/Tempo/Path.

Ready-made sinks

Copy one of these into your robot project and pass it to everything.

They’re written for WPILib 2026. On WPILib 2027 the imports and headers change as listed in 2026 vs 2027.

They’re written for RobotPy 2026. On RobotPy 2027 the imports change as listed in 2026 vs 2027.

On 2027 alpha-7 and later, Java can use the WPILib Telemetry sink at the end of this section instead.

NetworkTables

This sink adds a / to the front of each key, because NetworkTables treats Tempo/Pose and /Tempo/Pose as two different topics.

Java
import com.tempo.logging.TempoLogSink;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.networktables.BooleanPublisher;
import edu.wpi.first.networktables.DoublePublisher;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.StringPublisher;
import edu.wpi.first.networktables.StructArrayPublisher;
import edu.wpi.first.networktables.StructPublisher;
import java.util.HashMap;
import java.util.Map;

public final class NetworkTablesSink implements TempoLogSink {
    private final NetworkTableInstance nt = NetworkTableInstance.getDefault();
    private final Map<String, StructPublisher<Pose2d>> poses = new HashMap<>();
    private final Map<String, StructArrayPublisher<Pose2d>> paths = new HashMap<>();
    private final Map<String, DoublePublisher> numbers = new HashMap<>();
    private final Map<String, StringPublisher> texts = new HashMap<>();
    private final Map<String, BooleanPublisher> flags = new HashMap<>();

    @Override public void pose(String key, Pose2d value) {
        poses.computeIfAbsent(key, k -> nt.getStructTopic(topic(k), Pose2d.struct).publish())
            .set(value);
    }
    @Override public void poses(String key, Pose2d[] value) {
        paths.computeIfAbsent(key, k -> nt.getStructArrayTopic(topic(k), Pose2d.struct).publish())
            .set(value);
    }
    @Override public void number(String key, double value) {
        numbers.computeIfAbsent(key, k -> nt.getDoubleTopic(topic(k)).publish()).set(value);
    }
    @Override public void text(String key, String value) {
        texts.computeIfAbsent(key, k -> nt.getStringTopic(topic(k)).publish()).set(value);
    }
    @Override public void flag(String key, boolean value) {
        flags.computeIfAbsent(key, k -> nt.getBooleanTopic(topic(k)).publish()).set(value);
    }

    // "Tempo/Pose" -> "/Tempo/Pose"
    private static String topic(String key) {
        return key.startsWith("/") ? key : "/" + key;
    }
}
Python
from ntcore import NetworkTableInstance
from wpimath.geometry import Pose2d


class NetworkTablesSink:
    def __init__(self):
        self.nt = NetworkTableInstance.getDefault()
        self.publishers = {}

    def __call__(self, key, value):
        publisher = self.publishers.get(key)
        if publisher is None:
            # "Tempo/Pose" -> "/Tempo/Pose"
            topic = key if key.startswith("/") else "/" + key
            if isinstance(value, Pose2d):
                publisher = self.nt.getStructTopic(topic, Pose2d).publish()
            elif isinstance(value, list):
                publisher = self.nt.getStructArrayTopic(topic, Pose2d).publish()
            elif isinstance(value, bool):
                publisher = self.nt.getBooleanTopic(topic).publish()
            elif isinstance(value, str):
                publisher = self.nt.getStringTopic(topic).publish()
            else:
                publisher = self.nt.getDoubleTopic(topic).publish()
            self.publishers[key] = publisher
        publisher.set(value)


network_tables_sink = NetworkTablesSink()
C++
#include <map>
#include <string>
#include <vector>

#include <frc/geometry/Pose2d.h>
#include <networktables/BooleanTopic.h>
#include <networktables/DoubleTopic.h>
#include <networktables/NetworkTableInstance.h>
#include <networktables/StringTopic.h>
#include <networktables/StructArrayTopic.h>
#include <networktables/StructTopic.h>
#include <tempo/wpi/TempoLogging.h>

class NetworkTablesSink final : public tempo::wpi::TempoLogSink {
public:
    void pose(const std::string& key, const frc::Pose2d& value) override {
        auto [it, added] = poses_.try_emplace(key);
        if (added) it->second = nt_.GetStructTopic<frc::Pose2d>(Topic(key)).Publish();
        it->second.Set(value);
    }
    void poses(const std::string& key, const std::vector<frc::Pose2d>& value) override {
        auto [it, added] = paths_.try_emplace(key);
        if (added) it->second = nt_.GetStructArrayTopic<frc::Pose2d>(Topic(key)).Publish();
        it->second.Set(value);
    }
    void number(const std::string& key, double value) override {
        auto [it, added] = numbers_.try_emplace(key);
        if (added) it->second = nt_.GetDoubleTopic(Topic(key)).Publish();
        it->second.Set(value);
    }
    void text(const std::string& key, const std::string& value) override {
        auto [it, added] = texts_.try_emplace(key);
        if (added) it->second = nt_.GetStringTopic(Topic(key)).Publish();
        it->second.Set(value);
    }
    void flag(const std::string& key, bool value) override {
        auto [it, added] = flags_.try_emplace(key);
        if (added) it->second = nt_.GetBooleanTopic(Topic(key)).Publish();
        it->second.Set(value);
    }

private:
    // "Tempo/Pose" -> "/Tempo/Pose"
    static std::string Topic(const std::string& key) {
        return key.starts_with('/') ? key : "/" + key;
    }

    nt::NetworkTableInstance nt_ = nt::NetworkTableInstance::GetDefault();
    std::map<std::string, nt::StructPublisher<frc::Pose2d>> poses_;
    std::map<std::string, nt::StructArrayPublisher<frc::Pose2d>> paths_;
    std::map<std::string, nt::DoublePublisher> numbers_;
    std::map<std::string, nt::StringPublisher> texts_;
    std::map<std::string, nt::BooleanPublisher> flags_;
};

SmartDashboard

SmartDashboard has no pose type, so this sink writes each pose as an [x, y, degrees] number array. That is the format its field widgets read.

Java
import com.tempo.logging.TempoLogSink;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public final class SmartDashboardSink implements TempoLogSink {
    @Override public void pose(String key, Pose2d value) {
        SmartDashboard.putNumberArray(key, new double[] {
            value.getX(), value.getY(), value.getRotation().getDegrees()});
    }
    @Override public void poses(String key, Pose2d[] value) {
        double[] flat = new double[3 * value.length];
        for (int i = 0; i < value.length; i++) {
            flat[3 * i] = value[i].getX();
            flat[3 * i + 1] = value[i].getY();
            flat[3 * i + 2] = value[i].getRotation().getDegrees();
        }
        SmartDashboard.putNumberArray(key, flat);
    }
    @Override public void number(String key, double value) {
        SmartDashboard.putNumber(key, value);
    }
    @Override public void text(String key, String value) {
        SmartDashboard.putString(key, value);
    }
    @Override public void flag(String key, boolean value) {
        SmartDashboard.putBoolean(key, value);
    }
}
Python
from wpilib import SmartDashboard
from wpimath.geometry import Pose2d


def flat(pose):
    return [pose.X(), pose.Y(), pose.rotation().degrees()]


def smart_dashboard_sink(key, value):
    if isinstance(value, Pose2d):
        SmartDashboard.putNumberArray(key, flat(value))
    elif isinstance(value, list):
        SmartDashboard.putNumberArray(key, [n for pose in value for n in flat(pose)])
    elif isinstance(value, bool):
        SmartDashboard.putBoolean(key, value)
    elif isinstance(value, str):
        SmartDashboard.putString(key, value)
    else:
        SmartDashboard.putNumber(key, value)
C++
#include <string>
#include <vector>

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

class SmartDashboardSink final : public tempo::wpi::TempoLogSink {
public:
    void pose(const std::string& key, const frc::Pose2d& value) override {
        frc::SmartDashboard::PutNumberArray(key, Flat({value}));
    }
    void poses(const std::string& key, const std::vector<frc::Pose2d>& value) override {
        frc::SmartDashboard::PutNumberArray(key, Flat(value));
    }
    void number(const std::string& key, double value) override {
        frc::SmartDashboard::PutNumber(key, value);
    }
    void text(const std::string& key, const std::string& value) override {
        frc::SmartDashboard::PutString(key, value);
    }
    void flag(const std::string& key, bool value) override {
        frc::SmartDashboard::PutBoolean(key, value);
    }

private:
    static std::vector<double> Flat(const std::vector<frc::Pose2d>& poses) {
        std::vector<double> out;
        for (const auto& pose : poses) {
            out.push_back(pose.X().value());
            out.push_back(pose.Y().value());
            out.push_back(pose.Rotation().Degrees().value());
        }
        return out;
    }
};

DataLog

This sink writes to the robot’s DataLog file without going through NetworkTables. DataLogManager.getLog() starts the log if DataLogManager.start() hasn’t been called.

Java
import com.tempo.logging.TempoLogSink;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.util.datalog.BooleanLogEntry;
import edu.wpi.first.util.datalog.DataLog;
import edu.wpi.first.util.datalog.DoubleLogEntry;
import edu.wpi.first.util.datalog.StringLogEntry;
import edu.wpi.first.util.datalog.StructArrayLogEntry;
import edu.wpi.first.util.datalog.StructLogEntry;
import edu.wpi.first.wpilibj.DataLogManager;
import java.util.HashMap;
import java.util.Map;

public final class DataLogSink implements TempoLogSink {
    private final DataLog log = DataLogManager.getLog();
    private final Map<String, StructLogEntry<Pose2d>> poses = new HashMap<>();
    private final Map<String, StructArrayLogEntry<Pose2d>> paths = new HashMap<>();
    private final Map<String, DoubleLogEntry> numbers = new HashMap<>();
    private final Map<String, StringLogEntry> texts = new HashMap<>();
    private final Map<String, BooleanLogEntry> flags = new HashMap<>();

    @Override public void pose(String key, Pose2d value) {
        poses.computeIfAbsent(key, k -> StructLogEntry.create(log, k, Pose2d.struct)).append(value);
    }
    @Override public void poses(String key, Pose2d[] value) {
        paths.computeIfAbsent(key, k -> StructArrayLogEntry.create(log, k, Pose2d.struct))
            .append(value);
    }
    @Override public void number(String key, double value) {
        numbers.computeIfAbsent(key, k -> new DoubleLogEntry(log, k)).append(value);
    }
    @Override public void text(String key, String value) {
        texts.computeIfAbsent(key, k -> new StringLogEntry(log, k)).append(value);
    }
    @Override public void flag(String key, boolean value) {
        flags.computeIfAbsent(key, k -> new BooleanLogEntry(log, k)).append(value);
    }
}
Python
from wpilib import DataLogManager
from wpimath.geometry import Pose2d
from wpiutil import wpistruct
from wpiutil.log import BooleanLogEntry, DoubleLogEntry, RawLogEntry, StringLogEntry


class DataLogSink:
    def __init__(self):
        self.log = DataLogManager.getLog()
        self.log.addStructSchema(Pose2d)
        self.entries = {}

    def __call__(self, key, value):
        entry = self.entries.get(key)
        if entry is None:
            # RobotPy 2026.2.2's StructLogEntry raises "Object is closed",
            # so poses are packed here and written as raw struct records.
            if isinstance(value, Pose2d):
                entry = RawLogEntry(self.log, key, "", "struct:Pose2d")
            elif isinstance(value, list):
                entry = RawLogEntry(self.log, key, "", "struct:Pose2d[]")
            elif isinstance(value, bool):
                entry = BooleanLogEntry(self.log, key)
            elif isinstance(value, str):
                entry = StringLogEntry(self.log, key)
            else:
                entry = DoubleLogEntry(self.log, key)
            self.entries[key] = entry
        if isinstance(value, Pose2d):
            value = wpistruct.pack(value)
        elif isinstance(value, list):
            value = wpistruct.packArray(value)
        entry.append(value)


data_log_sink = DataLogSink()
C++
#include <map>
#include <string>
#include <vector>

#include <frc/DataLogManager.h>
#include <frc/geometry/Pose2d.h>
#include <tempo/wpi/TempoLogging.h>
#include <wpi/DataLog.h>

class DataLogSink final : public tempo::wpi::TempoLogSink {
public:
    void pose(const std::string& key, const frc::Pose2d& value) override {
        auto [it, added] = poses_.try_emplace(key, log_, key);
        it->second.Append(value);
    }
    void poses(const std::string& key, const std::vector<frc::Pose2d>& value) override {
        auto [it, added] = paths_.try_emplace(key, log_, key);
        it->second.Append(value);
    }
    void number(const std::string& key, double value) override {
        auto [it, added] = numbers_.try_emplace(key, log_, key);
        it->second.Append(value);
    }
    void text(const std::string& key, const std::string& value) override {
        auto [it, added] = texts_.try_emplace(key, log_, key);
        it->second.Append(value);
    }
    void flag(const std::string& key, bool value) override {
        auto [it, added] = flags_.try_emplace(key, log_, key);
        it->second.Append(value);
    }

private:
    wpi::log::DataLog& log_ = frc::DataLogManager::GetLog();
    std::map<std::string, wpi::log::StructLogEntry<frc::Pose2d>> poses_;
    std::map<std::string, wpi::log::StructArrayLogEntry<frc::Pose2d>> paths_;
    std::map<std::string, wpi::log::DoubleLogEntry> numbers_;
    std::map<std::string, wpi::log::StringLogEntry> texts_;
    std::map<std::string, wpi::log::BooleanLogEntry> flags_;
};

AdvantageKit

Logger.recordOutput takes each kind of value directly, and the outputs are recorded again during replay.

Java
import com.tempo.logging.TempoLogSink;
import edu.wpi.first.math.geometry.Pose2d;
import org.littletonrobotics.junction.Logger;

public final class AdvantageKitSink implements TempoLogSink {
    @Override public void pose(String key, Pose2d value) { Logger.recordOutput(key, value); }
    @Override public void poses(String key, Pose2d[] value) { Logger.recordOutput(key, value); }
    @Override public void number(String key, double value) { Logger.recordOutput(key, value); }
    @Override public void text(String key, String value) { Logger.recordOutput(key, value); }
    @Override public void flag(String key, boolean value) { Logger.recordOutput(key, value); }
}

Tempo times routes with Timer.getTimestamp(), which AdvantageKit sets to the log’s timestamps during replay. With the pose, measured speeds and sensors replayed as AdvantageKit inputs, a replay runs the same route logic and fires the same hooks as the original run. Two things can still differ:

  • With background planning (the default), a plan can be ready a loop earlier or later in the replay than it was on the robot. PlanningConfigs.inBackground(false) plans in the robot loop, and each plan is then ready on the same loop in both runs. It has to be set when the log is recorded too, and each plan then stalls the robot loop. For a log recorded in simulation, setting the environment variable TEMPO_PLANNING_MODE=replay on the simulation and on the replay does the same.
  • The timing item measures the computer running the code.

WPILib Telemetry (2027 alpha-7 and later)

WPILib 2027 alpha-7 added Telemetry, which sends each value to the configured backends. Earlier 2027 alphas don’t have it, so use the NetworkTables or DataLog sink on those.

Java
import com.tempo.logging.TempoLogSink;
import org.wpilib.math.geometry.Pose2d;
import org.wpilib.telemetry.Telemetry;

public final class TelemetrySink implements TempoLogSink {
    @Override public void pose(String key, Pose2d value) { Telemetry.log(key, value, Pose2d.struct); }
    @Override public void poses(String key, Pose2d[] value) { Telemetry.log(key, value, Pose2d.struct); }
    @Override public void number(String key, double value) { Telemetry.log(key, value); }
    @Override public void text(String key, String value) { Telemetry.log(key, value); }
    @Override public void flag(String key, boolean value) { Telemetry.log(key, value); }
}

Write a custom sink

  • Create a publisher or log entry the first time a key shows up, and keep it.
  • Per-loop items arrive every robot loop while a route runs, so a sink that blocks (for example by writing a file directly) stalls the loop.
  • Pick the method by the kind of value and not by the key. In Python, check for bool before numbers, because a bool is also an int.
  • Treat the values as read-only, because some are arrays or objects that other consumers receive too.

The pose is the first item each loop and timing is the last. If your sink writes one timestamp per loop, take it when the pose arrives. The full order is in TempoLogging.

If it fails…

Nothing is logged Above →

A route reads the consumers when it starts, so apply() only affects routes that start after it. Install the consumers once, after Tempo.configure(...).

AdvantageScope finds no logs on the roboRIO Above →

With no USB stick, DataLogManager writes to /home/lvuser/logs, and AdvantageScope looks in /U/logs. Point AdvantageScope at /home/lvuser/logs or plug in a USB stick.

esc

Loading search...