5.5 Ending early and robot actions
A path defines where the robot goes. An auto combines paths and commands. This page covers early drive endings and the names that connect commands and conditions to robot code.
Ending early belongs to a drive in an auto
A path is reused. The same pickup path can end when the intake has a piece in one auto and run to its end in another. So ending early is set where the path is used, on a drive step in an auto. The drive step’s inspector has an Ending early section under its path. It stays collapsed until one of its rows is set:
- End when (Simple names: Until): a sensor, or a typed code name, that ends the drive when it is true.
- Give up after (Time limit): seconds of driving after which the drive ends and counts as failed.
- Run on failure (If it fails): a command that runs when the robot stalls on the drive or reaches the time limit. None runs nothing.
Each row is a whole-run entry of the step’s commands (RunCommand with phase
endWhen, giveUpAfter or onFailure and no leg). The Setlist bindings
accept these after .drive(path). Java spells them .endWhen(...),
.giveUpAfter(Seconds.of(t)) and .runOnFailure(cmd). Python and C++ spell
them .end_when(...), .give_up_after(t) and .run_on_failure(cmd). Code
view reads and writes these entries. Ending early edits them for the whole
run. The Waypoint commands list offers them at individual waypoints, stored on
the leg that ends there.
The outline marks such a step with a flag whose label says what it does.
The robot runtime detects a stall after 0.75 s without 5 cm of progress. Once only a leg’s heading is owed, it detects one after 2 s without 1 degree of heading progress. The GUI offers a time limit and a failure command, but the stall thresholds are not configurable. A failed drive lets the auto continue. Setlist has no verb that ends the whole auto when a drive fails.
Paths keep the ending they already have
Composer’s endWhen, giveUpAfter and runOnFailure belong to a path. Saved
paths and Code view preserve these conditions when loading and exporting. They
apply when the path runs on its own or in an auto. The waypoint inspector
shows one read-only line, Ends early, that describes what the leg does (for
example “until Has piece · 4 s limit · then Stow”). The Clear next to it
removes all three in one undo step.
A saved fail case with no command runs nothing, so migratePath drops it on
load and keeps its deadline as the leg’s time limit.
A command or sensor is a name
A team adds a command by typing its name. Tempo derives a code identifier from
that label. It uses lowerCamelCase for Java and C++ and snake_case for Python,
with a make prefix for a C++ command factory. Spin up becomes spinUp, spin_up and
makeSpinUp (features/bindings/codeNames.ts). A code name entered by hand takes
precedence. Renaming the label preserves an existing code name, so references in
robot code keep compiling. If the derived name belongs to another command or
sensor, Tempo appends the first available number, so Spin up and Spin-up
become spinUp and spinUp2. Blank code names are filled whenever the
registry is loaded, imported or edited, except a field the team has just
emptied while retyping it. Export is blocked by a missing code name only when
Tempo cannot derive a valid identifier from the label, such as a name that
starts with a digit.
Loading a registry with blank names and adding an entry use the same name
allocator (allocateCodeNames, with allocateCppNames for C++).
In each language one pool holds every name already set and the names robot code
has in scope (features/bindings/reservedNames.ts). Those are keywords, Tempo’s
own public names, read from tests/fixtures/api/*.txt, Python’s builtins, C and
C++ macros such as errno and Windows’ min and max, and the modules and
namespaces a robot project uses. A derived name already in the pool takes a number,
so Tempo command becomes tempo_command2 in Python and errno errno2 in C++.
Commands come first, in the order they were created, then sensors. In C++ each
command’s factory, handle and owner receive names at that command’s turn, so
123 and 123 handle give make123, make123Handle (the handle) and
make123Handle2. node gui/web/scripts/reserved-names.mjs writes the
generated part of the pool again after the API surface changes.
Each command and sensor shows the line to paste into robot code, with Copy
(features/bindings/robotStub.ts). The line is a marked declaration that
compiles and does nothing yet, such as
@TempoCommand Command spinUp = Commands.none(); or
TEMPO_SENSOR hasPiece = [] { return false; };. The team replaces the
placeholder with the real command or condition.
Commands & Sensors is one column per item at the left sidebar’s density: Name, Code name and In robot code first, then More with Drives the robot and the footprint change, then where the item is used. A new command starts as not driving because most robot actions run alongside a drive. Checking Drives the robot marks one that uses the drivetrain.