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

4.12 Composer

A Composer holds one route’s start pose, its waypoints in order and the options for each leg. A leg is the drive from one waypoint to the next. A Setlist puts routes together with commands and waits.

Define and run a route

Call Tempo.configure(...) (tempo::wpi::configure(...) in C++) before you build a route. The example uses REEFSCAPE 2025 coordinates, so it needs the REEFSCAPE 2025 pack loaded.

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

var approach = Composer.named("Approach").startAt(new Pose2d(7.58, 5.85, Angles.deg(180)))
    .originAlliance(Alliance.BLUE)
    .to(5.13, 5.14, Angles.deg(-120));
approach.schedule();
Python
from tempo import Alliance, Composer
from wpimath.geometry import Pose2d
from tempo.angles import deg

approach = (Composer.named("Approach").start_at(Pose2d(7.58, 5.85, deg(180)))
    .origin_alliance(Alliance.BLUE)
    .to(5.13, 5.14, deg(-120)))
approach.schedule()
C++
#include <tempo/Angles.h>
#include <tempo/Composer.h>
#include <tempo/wpi/Setlist.h>

auto approach = tempo::Composer::named("Approach").start_at(7.58, 5.85, tempo::angles::deg(180))
    .origin_alliance(tempo::Alliance::Blue)
    .to(5.13, 5.14, tempo::angles::deg(-120));
approach.schedule();
FactoryResult
Composer.named(name).startAt(pose)A named auto on TempoAutos.chooser(). A blank name is refused
Composer.named(name).to(target)A named auto from the live pose
Composer.startAt(pose)An unnamed route
Tempo.composer(pose)Same as Composer.startAt(pose)
Tempo.to(target)An unnamed route from the live pose (point to point)

startAt (start_at) takes a Pose2d and then an optional Bias, and Python and C++ also take x, y, heading_rad in meters and radians. Java’s x, y form always takes a bias, startAt(x, y, heading, bias), and its heading is a Rotation2d or radians.

Option scope

Route-level methods and avoid zones apply to the whole route. speed and limits go before the to(...) they apply to. Every other option follows the to(...) of its leg, except a sticky option written before the first to(...).

ScopeOptionsApplies to
Forwardspeed, limitsThe next to(...) onward, until changed
StickyThe other Motion options: arrival, control, gains, replanning, curve, extensionThe leg they follow onward, until changed
Leg onlyRotation, routing, completion, commandsThe leg they follow. Two last longer than their leg: a Rotation Lock holds until its Key, and a runWhile command can run until the route ends. finallyDo is route-level

On a Tempo.to(target) route, speed and limits written right after it also apply to the leg to that target.

Before the first to(...), a sticky option sets the default for every leg and a leg-only option other than finallyDo throws. A call that throws changes nothing, and the route can still be edited.

Legs are numbered from 1 in the order of their to(...) calls, the same way console lines number them. This example uses the bundled REBUILT 2026 pack, where bumpLeft is a terrain id, and cross applies to leg 2:

Java
import com.tempo.Composer;
import com.tempo.Terrain;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;

Composer bumpCross = Composer.startAt(new Pose2d(2.0, 5.55, Rotation2d.kZero))
    .to(3.30, 5.55)                         // leg 1
    .to(5.60, 5.55)                         // leg 2
        .cross(Terrain.named("bumpLeft"))   // applies to leg 2
    .to(7.00, 4.50);                        // leg 3
Python
from tempo import Composer, Terrain
from wpimath.geometry import Pose2d

bump_cross = (Composer.start_at(Pose2d(2.0, 5.55, 0.0))
    .to(3.30, 5.55)                         # leg 1
    .to(5.60, 5.55)                         # leg 2
        .cross(Terrain.named("bumpLeft"))   # applies to leg 2
    .to(7.00, 4.50))                        # leg 3
C++
#include <tempo/Composer.h>
#include <tempo/Terrain.h>

auto bump_cross = tempo::Composer::start_at(2.0, 5.55, 0.0)
    .to(3.30, 5.55)                                // leg 1
    .to(5.60, 5.55)                                // leg 2
        .cross(tempo::Terrain::named("bumpLeft"))  // applies to leg 2
    .to(7.00, 4.50);                               // leg 3

Method index

Python and C++ methods are snake_case (origin_alliance, is_finished, Arrival::through(0.8)). The few capitalized C++ names, such as Bias::Toward, Arrival::Through() and Arrival::Stop(), are listed on the overview. Where Java takes a Time, Distance or Angle, Python takes a plain float in seconds, meters or radians, and None where Java takes null.

Route-level

MethodEffectDefault
originAlliance(alliance)The authoring frame. NEUTRAL never mirrorsBLUE
resetOdometry(bool)Reset odometry to the start. In Python and C++ a call with no argument passes truefalse
preplanAhead(n)Planning units kept planned ahead. A negative value clamps to 0 here and throws on the configconfig, 2
schedule(), command()Schedule the route, or build its command (C++ tempo::wpi::command(route))
start()Run it without the scheduler
isFinished(), cancel()Whether the latest run, from schedule() or start(), has ended, and a call that ends it
warmup(), isFrozen()Plan the next run while disabled, and whether the route is frozen
getStartPose(), getEndPose()Where the route starts and ends for the alliance the robot is on, as an Optional<Pose2d>. The start is empty without startAt. The end is empty when the last target is supplied, has an aim, arriveWith or until, or its heading is only known while driving. C++ takes the pose type, as in get_start_pose<frc::Pose2d>()
handle()A RouteHandle (Java only)

Avoid zones

MethodEffect
avoid(region)Keep the planned path out of a custom Region
ignore(zone)Turn a pack avoid zone off for this route, so the path can go through it
allow(zone)Turn a pack avoid zone on for this route, so the path stays out of it. It doesn’t let the robot into the zone. Use it for a zone the pack starts switched off or one an earlier ignore turned off, and the later call wins

The example adds two avoid zones to the REEFSCAPE 2025 pack, and protectedZone starts switched off.

TOML
[[regions]]
id = "stagingArea"
shape = "rectangle"
minM = [3.0, 0.5]
maxM = [4.5, 2.5]
effect = "avoid"

[[regions]]
id = "protectedZone"
shape = "rectangle"
minM = [6.0, 0.0]
maxM = [7.5, 2.0]
effect = "avoid"
enabled = false
Java
import com.tempo.Region;
import com.tempo.Zone;

Composer.startAt(start)
    .ignore(Zone.named("stagingArea"))      // pack zone, off for this route
    .allow(Zone.named("protectedZone"))     // pack zone, obeyed on this route
    .avoid(Region.circle(2.0, 4.03, 0.6))   // custom region
    .to(target);
Python
from tempo import Region, Zone

(Composer.start_at(start)
    .ignore(Zone.named("stagingArea"))      # pack zone, off for this route
    .allow(Zone.named("protectedZone"))     # pack zone, obeyed on this route
    .avoid(Region.circle(2.0, 4.03, 0.6))   # custom region
    .to(target))
C++
#include <tempo/Region.h>

tempo::Composer::start_at(start)
    .ignore(tempo::Zone::named("stagingArea"))      // pack zone, off for this route
    .allow(tempo::Zone::named("protectedZone"))     // pack zone, obeyed on this route
    .avoid(tempo::Region::circle(2.0, 4.03, 0.6))   // custom region
    .to(target);

A target inside an avoid zone can’t be planned, and that includes a custom zone made larger with grownBy or near. A route can start inside an avoid zone and drive out.

Targets

to(...) takes x, y, x, y, heading, a Translation2d, a Pose2d, or in Python a tuple, and then an optional Bias. The robot faces the heading when it arrives, and what it does at a target with no heading depends on the drivetrain (Rotation). Java takes the heading as a Rotation2d, Python takes radians or a Rotation2d and C++ takes radians.

to(...) also takes a supplier of a pose or a point: Java PoseSupplier or Supplier<Translation2d>, a Python callable, or a C++ std::function returning a std::optional. It’s read once when the route starts, in the field frame the robot drives in, and it never mirrors.

Java
import com.tempo.Angles;
import com.tempo.Bias;

route.to(6.20, 4.00, Bias.toward(Angles.deg(-90), 0.8))
    .to(5.13, 5.14, Angles.deg(-120));
Python
from tempo import Bias
from tempo.angles import deg

route.to(6.20, 4.00, Bias.toward(deg(-90), 0.8)).to(5.13, 5.14, deg(-120))
C++
#include <tempo/Angles.h>
#include <tempo/Bias.h>

route.to(6.20, 4.00, tempo::Bias::Toward(tempo::angles::deg(-90), 0.8))
    .to(5.13, 5.14, tempo::angles::deg(-120));

An off-field or non-finite coordinate throws. This is the message with the bundled REBUILT 2026 pack and a robot circumradius of 0.500 m:

route target x = 25.0 m is off the field; the pack is 16.541 x 8.069 m and a route coordinate may sit at most 0.500 m (one robot circumradius) outside it. Check for transposed x/y, centimetres, or inches

A target equal to the previous one is allowed.

Motion

limits and speed are forward options and the rest of this table is sticky (Option scope).

MethodEffect
limits(v, a, c[, omega, alpha]), limits(constraints)Caps on velocity (m/s), acceleration and centripetal acceleration (m/s^2), and optionally turn rate (rad/s) and turn acceleration (rad/s^2)
speed(Speed)A speed level
arrival(Arrival)Carry, stop or pause
control(Control)The path follower
gains(...)Tracking gains
replanning(...), noReplanning()Replanning policy
curve(CurveStyle)SMOOTH (default) or STRAIGHT
extension(RobotExtension)Footprint growth

gains(null) (None, std::nullopt) restores the robot setting. For replanning, Java takes (ReplanSettings) null, Python None and C++ std::nullopt.

Rotation (per leg)

MethodEffect
rotationTarget(fraction, heading[, turnRate])Face heading by fraction of the leg. Several stack
aimTarget([window,] target[, turnRate])Point at a fixed or live target
facingTravel()Face the direction of travel along the path
rotationLock(position), rotationKey(position)A Lock holds the robot’s heading from position on, and a later Key releases it at its position

Positions are fractions of the leg’s path distance. The details are on Rotation targeting.

Rotation Locks and Keys

A Lock holds whatever heading the robot has when it reaches the Lock’s position. The hold carries across waypoints until a Key releases it.

Java
Composer.startAt(start)
    .to(trenchEntry)
        .rotationLock(0.5)
    .to(trenchExit)
    .to(destination)
        .rotationKey(0.3);
Python
(Composer.start_at(start)
    .to(trench_entry)
        .rotation_lock(0.5)
    .to(trench_exit)
    .to(destination)
        .rotation_key(0.3))
C++
tempo::Composer::start_at(start)
    .to(trench_entry)
        .rotation_lock(0.5)
    .to(trench_exit)
    .to(destination)
        .rotation_key(0.3);
  • A Lock takes priority, so inside a locked stretch a rotation target or waypoint heading is ignored and an aim doesn’t turn the robot. A rotation target at the same position as a Lock is reached before the hold begins.
  • Inside the stretch the planner can use the footprint at the held heading, and it plans through a gap too narrow to turn in when that’s faster.
  • The turn after a Key runs at the angular limits. If the turn can’t finish by the leg’s end at the speed the leg would carry into the next one, the leg stops at its end.
  • A leg has no route if no plan can hold every Lock on it. Differential drives ignore Locks and Keys.

A heading or an aim inside a locked stretch, and a Lock no Key releases, each print a warning naming the leg to the runtime log and in Tempo’s GUI, for example:

[Tempo] leg 2: a Rotation Lock is never released by a Rotation Key; the robot holds its heading to the end of the route.

A position outside 0 to 1 throws:

[Tempo] a Rotation Lock or Key position must be a fraction from 0 to 1; got {value}

Routing (per leg)

MethodEffect
stayWithin(Region), stayWithin(Zone)Keep the planned path inside a region or pack element
cross(Terrain)Cross the named terrain on the leg it follows. Several cross in call order

practiceRamp is the terrain id in the sample pack on the file format page. The REEFSCAPE 2025 pack has no terrain, so use an id from your own pack.

Java
import com.tempo.Composer;
import com.tempo.Terrain;

var crossing = Composer.startAt(start)
    .to(target)
    .cross(Terrain.named("practiceRamp"));
Python
from tempo import Composer, Terrain

crossing = (Composer.start_at(start)
    .to(target)
    .cross(Terrain.named("practiceRamp")))
C++
#include <tempo/Composer.h>
#include <tempo/Terrain.h>

auto crossing = tempo::Composer::start_at(start)
    .to(target)
    .cross(tempo::Terrain::named("practiceRamp"));

Depth, targets, errors and the console lines for a crossing that can’t be driven are on Regions, zones and terrain.

Completion (per leg)

MethodEffect
giveUpAfter(duration)End the leg after this long and move to the next. Java Time, Python and C++ seconds
endWhen(check)End the leg early
runOnFailure(recovery)Run on no route, a stall, the giveUpAfter time running out, a missed crossing, or a fault while this leg is driving
arriveWithin(translation, heading)Arrival tolerance for this leg. Java Distance and Angle, Python and C++ meters and radians

A missed arrival on its own doesn’t run a leg’s recovery, but it does start the runOnFailure of a run in a Setlist. A recovery still running when the route ends keeps running (Setlist). A driver command on one of its subsystems then ends it unless it was built with kCancelIncoming (CANCEL_INCOMING on 2027 alpha-7 and beyond), and disabling the robot ends it unless it was built with ignoringDisable(true). Canceling the auto in teleopInit doesn’t end a recovery that is already running on its own.

Commands (per leg)

MethodFires
runBefore(cmd)Before driving. Blocks
run(f, cmd)At fraction f. Doesn’t block
run(from, to, cmd)From from until to or the leg’s end. Needs 0 <= from <= to <= 1
run(condition, cmd)Once, when a Condition first holds
runWhile(condition, cmd)Each time a state holds, until the route ends
runAfter(cmd)After arrival or endWhen. Blocks, and is skipped when the leg fails
waitUntil(check[, timeout])After arrival, in order with runAfter
arriveWith([fraction,] cmd)A drivetrain command performs the arrival
finallyDo(action)Once as the route ends, however it ends. It belongs to the whole route, wherever it is written

A hook is a command one of these methods attaches to a leg. A blocking hook holds the robot still until it finishes, and blocking hooks run in the order they’re written. Hooks also take actions, checks and Setlists with no drive (Run commands on a route).

A leg that can’t be planned is skipped before its runBefore hooks run. Otherwise the leg is planned again from the latest pose after runBefore finishes.

A hook that starts takes over from a running hook that uses one of its subsystems. If the running one was built with kCancelIncoming (CANCEL_INCOMING on 2027 alpha-7 and beyond), the new hook doesn’t start and Tempo prints a line naming both.

Hooks aren’t scheduled on their own, so starting one never interrupts its auto. A hook can still end the auto by calling cancel() or Tempo.stop().

A command factory annotated -> Command needs requirements=[...], or the route throws when it freezes. A factory passed to arrive_with doesn’t need them.

Reading a route back

handle() returns a RouteHandle (Java only) for the run in progress or the last one. Every method is safe to call before the first run.

MethodAnswers
started(), phase()Whether the route has run, and the run’s phase, which reads CANCELLED after a normal finish as well as after a cancel
wedged()Commanded to move but not progressing
replans(), replanFailed()How many replans were installed, and whether one failed
skippedSegments(), skippedSegmentIndices()Legs with no route (a segment is a leg). The indices count from 0
missedSegments(), missedSegmentIndices()Missed legs: missed arrivals and legs that gave up or stalled short of the waypoint. The indices count from 0
droveEveryLeg(), arrivedEveryLeg()No leg skipped, and none skipped or missed
progress(nowS)The current leg (from 0), the leg count and the seconds since the auto started. nowS is WPILib’s Timer.getTimestamp()
expectedPose(nowS)The planned pose at nowS, also from Timer.getTimestamp(). null when the route isn’t driving

For droveEveryLeg() and arrivedEveryLeg():

  • A leg that settled outside its translation tolerance but within twice it, or that endWhen ended outside it, isn’t a miss, though the arrivals logging item’s reached is false for that leg.
  • Both are false before the first run.
  • Neither checks that the run finished. A run canceled part-way that skipped and missed nothing still reads true.

The state and plannedPose logging items give the current leg and the planned pose in every language.

Read these after the route finishes. The index arrays count legs from 0, one lower than the leg numbers in console lines.

Java
import com.tempo.RouteHandle;
import edu.wpi.first.wpilibj.DriverStation;
import java.util.Arrays;

// After the approach command has finished:
RouteHandle h = approach.handle();
if (!h.arrivedEveryLeg()) {
    DriverStation.reportError(
        "route skipped leg indices " + Arrays.toString(h.skippedSegmentIndices())
            + "; missed leg indices " + Arrays.toString(h.missedSegmentIndices()), false);
}

The reporting call is edu.wpi.first.wpilibj.DriverStation.reportError.

The reporting call is org.wpilib.driverstation.DriverStationErrors.reportError. See 2026 vs 2027.

Freeze and errors

A route freezes the first time it is used: command(), schedule(), start(), warmup(), the chooser’s planning while disabled, or a simulation. A route in a Setlist freezes when the Setlist does. Freezing checks the route and locks it, and later edits throw.

CauseMessage
Python and C++ only: a route made with the bare constructor Composer() and given no start pose. A route that begins with Tempo.to(...) or named(...).to(...) starts from the live pose and needs no start posePython Composer requires start_at(pose) before first use; C++ Composer requires start_at(pose) before use
No legComposer requires at least one completed segment
resetOdometry(true) on a Tempo.to(...) route[Tempo] a Composer with no start pose starts wherever the robot is and has no pose to reset odometry to; give it a start pose or stop resetting odometry
A differential-drive leg with no track width, which comes from TankConfigs.trackWidth(...)Control.standard() needs a differential drivetrain configured with TempoConfig.withTank(...), or an explicit track width

Python and C++ word the no-leg and track-width messages for their own calls.

Differential-drive rotation refusals are on Rotation targeting, and start bias on a differential drive is on Bias.

esc

Loading search...