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

TempoAutos holds every named auto and builds a chooser from them. It’s com.tempo.TempoAutos in Java and tempo.TempoAutos in Python.

C++ splits it into tempo::TempoAutos for the registry and tempo::wpi::TempoAutos (<tempo/wpi/TempoAutos.h>) for the chooser.

Chooser

Java
SendableChooser<Auto> autos = TempoAutos.chooser();
SendableChooser<Auto> withDefault = TempoAutos.chooser(twoPiece);
SendableChooser<Auto> competition = TempoAutos.chooser(only -> only.setlists().named("Comp.*"));
Python
autos = TempoAutos.chooser()
with_default = TempoAutos.chooser(two_piece)
competition = TempoAutos.chooser(lambda only: only.setlists().named("Comp.*"))
C++
#include <tempo/wpi/TempoAutos.h>

auto autos = tempo::wpi::TempoAutos::chooser();
auto withDefault = tempo::wpi::TempoAutos::chooser(twoPiece);
auto competition = tempo::wpi::TempoAutos::chooser(
    [](auto only) { return only.setlists().named("Comp.*"); });
CallListsDefault
chooser()Every registered auto, in registration orderNone
chooser(defaultAuto)Every registered autodefaultAuto, which must be registered
chooser(only)The autos the filter keepsNone

A filter chains setlists(), composers() and named(regex). setlists() keeps Setlists and composers() keeps named Composers, and with both or neither the filter keeps both kinds. named must match the whole name. With no default, an empty selection runs nothing.

Python’s chooser(...) takes one argument, either the default auto or the filter callable.

The C++ chooser is a std::shared_ptr, and the autos it lists must outlive it.

While the robot is disabled, Tempo pre-plans the auto picked on a TempoAutos chooser, and picking another auto plans again. The command scheduler has to keep running while the robot is disabled for this, or Tempo.update() if Tempo.configure(...) wasn’t given the drive subsystem. new PlanningConfigs().warmWhileDisabled(false) (warm_while_disabled(False) in Python, warm_while_disabled(false) in C++) turns it off.

chooser() returns SendableChooser<Auto> (Java), wpilib.SendableChooser (Python) or a std::shared_ptr to an frc::SendableChooser<tempo::Auto*> (C++). Publish it with putData, which in C++ is frc::SmartDashboard::PutData("Auto", autos.get()).

On alpha-6 it’s a SendableChooser, published with putData. On WPILib 2027 alpha-7 and beyond, Selectable from WPILib’s tunables library replaces it, so chooser() returns a Selectable. Publish it with Tunables.publish("Auto", autos) in Java, tunables.publish("Auto", autos) in Python, and wpi::tunables::Publish("Auto", *autos) in C++.

Your own chooser

JavaPythonC++Adds
populate(chooser)populate(chooser)populate(chooser)Every registered route, Setlist and calibration routine, as commands
populate(addOption, selected)The same, for a chooser such as AdvantageKit’s LoggedDashboardChooser

chooser is a chooser of commands the robot code built, a SendableChooser, or a Selectable on alpha-7 and beyond. In C++ populate is on tempo::wpi::TempoAutos, and the chooser has to last as long as the robot program.

populate doesn’t freeze anything. A listed auto freezes when its command is scheduled or put in a group, so put it in a group once the auto is complete. Autos registered later join the chooser, and the picked auto is pre-planned as it is on a TempoAutos chooser.

The auto’s own isFinished() and cancel() follow runs started with schedule() or start(). For a run started from the chooser, use the command the chooser returned.

Lookup

JavaPythonC++Returns
names()names()names()Registered names, in order
get(name)get(name)get(name)The auto, or null / None / nullptr
all()all()all()Every registered auto, in order
selected()selected()selected()The pick being pre-planned, or none
prePlan(supplier)pre_plan(fn)pre_plan(fn)Pre-plans what a team-built chooser answers

prePlan(myChooser::getSelected) pre-plans that pick even with warmWhileDisabled(false).

Registration

Java
TempoAutos.autoRegister(false);           // before any chooser is built
TempoAutos.register(twoPiece);            // under its own name
TempoAutos.register("Taxi", taxiRoute);   // an unnamed Composer, under a name
Python
TempoAutos.auto_register(False)
TempoAutos.register(two_piece)
TempoAutos.register("Taxi", taxi_route)
C++
tempo::TempoAutos::auto_register(false);
tempo::TempoAutos::register_auto(twoPiece);
tempo::TempoAutos::register_auto("Taxi", taxiRoute);

Setlist.named(...) and Composer.named(...) register themselves as they’re made. An unnamed Composer or Setlist never does.

  • autoRegister(false) turns self-registration off and removes every auto that registered itself. It can come before or after the autos are made, but before a chooser is built.
  • register(auto) registers a named auto under its own name.
  • register(name, auto) registers the auto under name, in place of the name it registered itself under. An unnamed Composer or Setlist registers this way.

C++ spells it register_auto, since register is a keyword.

An auto built again under the same name is discarded when it has the same content and uses the same command objects, and the first one stays registered. When they differ, the two autos clash. An auto built under a taken name that can’t freeze, such as an empty Setlist, counts as different.

  • Before the first enable, names(), get(), all(), chooser() and prePlan() throw the first message in the table. The disabled pre-planning loop doesn’t throw. It prints the second message once for the name, and the first auto keeps the name.
  • After the first enable no call throws. Each prints the second message once for the name, and the first auto keeps the name.
MessageCause
[Tempo] two different autos are named "Two Piece"; build it once or rename oneTwo autos with different content share a name. This one is thrown
[Tempo] two different autos are named "Two Piece"; the first one keeps the name. Build the auto once or rename oneThe same clash found by the robot loop, or by any call after the first enable. It is printed once and nothing is thrown
[Tempo] this auto has no name; start the Composer with Composer.named(...) or register it with a nameregister(auto) on an unnamed Composer
[Tempo] an auto name must not be blankA blank name given to Composer.named(...). Setlist.named(...) throws Setlist name must be non-blank
[Tempo] a chooser's default must be a registered autochooser(defaultAuto) with an unregistered auto
[Tempo] no command framework is installed; use TempoAutos.chooser()populate on a robot with no command framework
[Tempo] the command around this auto was made before the auto could freeze, so it does not hold the auto's subsystems; make it once the auto is completeA group holds a populate command whose auto couldn’t freeze when the group was made. The command ends without driving
[Tempo] auto registration was turned off after a chooser was built; turn it off before building oneautoRegister(false) too late
[Tempo] the auto "Two Piece" is already on a chooser; give it its final name before building oneRenamed after a chooser listed it
[Tempo] could not pre-plan the auto "Two Piece": {reason}Console line. Pre-planning failed

resetForTesting() (reset_for_testing()) forgets every auto, chooser and pick. The guide is Auto chooser.

esc

Loading search...