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

SimRun drives a Composer route against a point-mass robot, without WPILib simulation, and records each tick. SimAssert checks bounds on one run, and Realism adds motor lag, an acceleration limit, odometry noise and loop jitter. The classes are in com.tempo.sim (Java), tempo.sim (Python) and <tempo/sim/SimRun.h> (C++). The guide is Test an auto.

Running a route

Tempo must be configured with the robot and a matching pack (test setup), and these coordinates need the REEFSCAPE 2025 pack.

Java
import com.tempo.Angles;
import com.tempo.Composer;
import com.tempo.sim.SimRun;
import edu.wpi.first.math.geometry.Pose2d;

var route = Composer.startAt(new Pose2d(7.58, 5.85, Angles.deg(180)))
    .to(5.13, 5.14, Angles.deg(-120));
SimRun run = SimRun.of(route).go();
System.out.println(run.duration() + " s, max error " + run.maxError() + " m");
Python
from tempo import Composer
from tempo.angles import deg
from tempo.sim import SimRun
from wpimath.geometry import Pose2d

route = Composer.start_at(Pose2d(7.58, 5.85, deg(180))).to(5.13, 5.14, deg(-120))
run = SimRun.of(route).go()
print(run.duration_s, run.max_error_m, run.final_pose)
C++
#include <tempo/Tempo.h>
#include <tempo/sim/SimRun.h>
#include <tempo/wpi/Geometry.h>
#include <utility>

auto route = tempo::Composer::start_at(7.58, 5.85, tempo::angles::deg(180))
    .to(5.13, 5.14, tempo::angles::deg(-120));
auto run = tempo::SimRun::of(std::move(route));   // C++ moves the route in
run.go();
frc::Pose2d finalPose = tempo::wpi::final_pose(run);

go() schedules no command and blocks until the route ends or 60 simulated seconds pass, so call it from tests and desktop tools and never from the robot loop. The model ticks at 50 Hz. At an arriveWith handover it places the robot at the waypoint, at rest and at the waypoint’s heading if it has one, without running the command. The placement doesn’t count as tracking error.

JavaPythonC++Result
SimRun.of(route)SimRun.of(route)SimRun::of(std::move(route))Wraps the route. Nothing runs yet
startingAt(pose)starting_at(pose)starting_at(pose)Start pose for a route with none, such as Tempo.to(...)
withRealism(realism)with_realism(realism)with_realism(realism)Default Realism.none()
go()go()go()Runs and returns the run
duration()duration_sduration_s()Simulated time, s
maxError()max_error_mmax_error_m()Largest distance from the expected pose, m
frames()framesframes()One Frame per tick, 20 ms apart unless loopJitter is set
finalPose()final_posetempo::wpi::final_pose(run)Physical pose at the last tick
writeCsv(path)write_csv(path)write_csv(path)Tick data as CSV. Java takes a String or Path
fired()firedfired()Each hook the route scheduled, in order, as a Fired
firedAny(name)fired_any(name)fired_any(name)Whether a hook with that name fired
firstFiredAt(name)first_fired_at(name)first_fired_at(name)When it first fired, s. NaN when it never did

Python results are properties, read without parentheses.

Reading a result before go() throws call go() first. A Frame holds the time, pose (the reported Pose2d), command (the commanded ChassisSpeeds) and the tracking error. The time and error are timeS and errorM in Java and time_s and error_m in Python and C++.

C++ reads the pose and command with tempo::wpi::pose(frame) and tempo::wpi::command(frame).

go() refuses a start that doesn’t fit the route. Python and C++ spell the method starting_at in these messages:

[Tempo] a route with no start pose starts wherever the robot is; say where with SimRun.startingAt(pose)
[Tempo] SimRun.startingAt(pose) places the robot for a route with no start pose; this route starts at its own

CSV columns, one row per tick:

ColumnUnit
time_ss
x, ym, field frame
headingrad
vx, vy, omegam/s and rad/s, robot-relative command
error_mm from the expected pose

SimAssert

Java
import com.tempo.sim.SimAssert;
import static edu.wpi.first.units.Units.Meters;
import static edu.wpi.first.units.Units.Seconds;

SimAssert.that(route)
    .finishesWithin(Seconds.of(5))
    .staysWithin(Meters.of(0.15))
    .endsWithin(Meters.of(0.05))
    .check();
Python
from tempo.sim import SimAssert

(SimAssert.that(route)
    .finishes_within(5.0)        # s
    .stays_within(0.15)          # m
    .ends_within(0.05)           # m
    .check())
C++
// The first example moved its route into the SimRun, so this one builds another.
auto route = tempo::Composer::start_at(7.58, 5.85, tempo::angles::deg(180))
    .to(5.13, 5.14, tempo::angles::deg(-120));
tempo::SimAssert::that(std::move(route))
    .finishes_within(5.0)        // s
    .stays_within(0.15)          // m
    .ends_within(0.05)           // m
    .check();
JavaPython / C++Bound
finishesWithin(Time)finishes_within(s)Simulated duration
staysWithin(Distance)stays_within(m)Largest tracking error
endsWithin(Distance)ends_within(m)Final pose to the last target the run drove toward
withRealism(realism)with_realism(realism)Realism for the run
fires(name)fires(name)A hook with that name fires
neverFires(name)never_fires(name)No hook with that name fires
firesInOrder(names...)fires_in_order(*names) / fires_in_order({names})Those hooks fire in that relative order. Others may fire between

check() runs the route once and returns the SimRun. When a bound is broken it throws AssertionError (std::runtime_error in C++) naming the first one. Bounds that weren’t set aren’t checked. A skipped leg shortens the run and endsWithin can then pass on the wrong endpoint, so also compare finalPose() with the authored end (Test an auto).

A Fired records a hook decision without running the command. It holds the time, the command, its name, the leg and the auto’s phase (timeS and segmentIndex in Java, time_s and segment_index in Python and C++). A segment is a leg, and the index counts from 0. The name is the command’s own, and a hook made from a plain function is named runOnce, waitUntil or startEnd. The hook checks fail with messages like hook "shoot" never fired; the run scheduled [deploy, intake].

Realism

Java
import com.tempo.sim.Realism;

SimRun run = SimRun.of(route).withRealism(Realism.typical().seed(7)).go();
Python
from tempo.sim import Realism

run = SimRun.of(route).with_realism(Realism.typical().with_seed(7)).go()
C++
// A freshly built route, as above.
auto route = tempo::Composer::start_at(7.58, 5.85, tempo::angles::deg(180))
    .to(5.13, 5.14, tempo::angles::deg(-120));
auto run = tempo::SimRun::of(std::move(route));
run.with_realism(tempo::Realism::typical().with_seed(7)).go();
JavaPython / C++Effecttypical()
motorLagTau(s)motor_lag_tauFirst-order lag on commanded speeds. 0 is off0.10 s
accelLimit(mps2)accel_limitAcceleration clamp. 0 is unlimited6.0 m/s^2
odometryNoise(xyM, thetaRad)odometry_noisePer-tick random-walk sigma on the reported pose0.002 m, 0.001 rad
loopJitter(s)loop_jitterSigma on the loop period. 0 is a fixed 20 ms0.002 s
seed(long)with_seed(n)Noise seed42

Realism.none() is the default, with no lag, clamp, noise or jitter. Each modifier returns a new Realism.

In Python and C++ the seed method is with_seed, because seed is the field name.

With noise, frames() hold the reported pose the follower saw and finalPose() the true one. The same seed and inputs give the same frames in Java, Python and C++ on the same build.

Limits

  • There are no wheels, modules or terrain physics, and the noise is isotropic with no slip direction.
  • Blocking commands and arriveWith commands finish instantly, so their duration is missing from the timeline.
  • WPILib commands don’t run, so test mechanisms through the scheduler and measure tracking on the robot.
esc

Loading search...