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

3.12 Auto chooser

Examples: WPILib 2026

TempoAutos.chooser() returns a WPILib chooser with every named auto in it. Publish it, then schedule the selected auto in autonomousInit.

Publish every named auto

Java
import com.tempo.Auto;
import com.tempo.TempoAutos;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

private final SendableChooser<Auto> autos = TempoAutos.chooser();
private Auto auto;

@Override public void robotInit() { SmartDashboard.putData("Auto", autos); }

@Override public void autonomousInit() {
    auto = autos.getSelected();
    if (auto != null) auto.schedule();
}

@Override public void teleopInit() {
    if (auto != null) auto.cancel();
}
Python
from wpilib import SmartDashboard
from tempo import TempoAutos

def robotInit(self):
    self.autos = TempoAutos.chooser()
    self.auto = None
    SmartDashboard.putData("Auto", self.autos)

def autonomousInit(self):
    self.auto = self.autos.getSelected()
    if self.auto is not None:
        self.auto.schedule()

def teleopInit(self):
    if self.auto is not None:
        self.auto.cancel()
C++
#include <frc/smartdashboard/SmartDashboard.h>
#include <tempo/wpi/TempoAutos.h>

// Members: std::shared_ptr<tempo::wpi::AutoChooser> autos_; tempo::Auto* auto_ = nullptr;
void Robot::RobotInit() {
    autos_ = tempo::wpi::TempoAutos::chooser();
    frc::SmartDashboard::PutData("Auto", autos_.get());
}

void Robot::AutonomousInit() {
    auto_ = autos_->GetSelected();
    if (auto_) auto_->schedule();
}

void Robot::TeleopInit() {
    if (auto_) auto_->cancel();
}
Elastic with the Auto chooser open, listing Left coral, Ground intake left and Taxi, and nothing selected
Nothing is selected until a driver picks an auto. View full size (opens in a new tab) ↗

The chooser lists every Setlist.named(...) auto and every route written Composer.named("Taxi").startAt(...). A Setlist made with new Setlist() (Setlist() in Python and C++) and a Composer without a name aren’t listed. Calibration autos are listed too, unless the chooser is filtered with setlists() or composers(). Named autos register themselves as they’re made (this is called self-registration). An auto registered after TempoAutos.chooser() is built is still added to that chooser.

TempoAutos.chooser() sets no default, so if nothing is selected getSelected() returns null (None in Python, nullptr in C++) and no auto runs.

In teleopInit, cancel the auto that was started, as in the example, and not whatever the chooser has selected by then. If your robot doesn’t use the command scheduler, call start() instead of schedule() (Schedule and cancel).

While the robot is disabled, the selected auto’s routes are built and planned. Selecting a different auto plans that one instead. The paths are worked out on helper threads, but the command scheduler (or Tempo.update() if your robot doesn’t use it) has to keep running while the robot is disabled.

To turn off planning while disabled, use warmWhileDisabled(false) on the planning config. If Tempo finds no path to a waypoint, it prints a [Tempo] auto '...': no path was found ... line once while the robot is still disabled.

In C++ the chooser holds pointers, so every auto has to outlive the chooser that lists it.

TempoAutos.chooser() returns a SendableChooser, published with putData as above.

On the alpha-6 vendordep, TempoAutos.chooser() returns a SendableChooser, published with putData as above. On WPILib 2027 alpha-7 and beyond, the tunables library’s Selectable replaces it, so TempoAutos.chooser() returns a Selectable. Publish it through the tunables registry with Tunables.publish("Auto", autos) in Java, tunables.publish("Auto", autos) in Python and wpi::tunables::Publish("Auto", *autos_) in C++. Python reads the pick there with autos.get_selected().

Default and filters

TempoAutos.chooser(leftCoral) lists every auto with leftCoral selected by default. leftCoral stands for one of your named autos (in C++ a tempo::Auto&). chooser(...) also takes a filter instead of a default auto, and the filter limits which autos are listed:

Java
TempoAutos.chooser(only -> only.setlists());                  // Setlists only
TempoAutos.chooser(only -> only.composers());                 // named Composers only
TempoAutos.chooser(only -> only.setlists().named("Comp.*"));  // Setlists named Comp...
Python
TempoAutos.chooser(lambda only: only.setlists())                  # Setlists only
TempoAutos.chooser(lambda only: only.composers())                 # named Composers only
TempoAutos.chooser(lambda only: only.setlists().named("Comp.*"))  # Setlists named Comp...
C++
tempo::wpi::TempoAutos::chooser([](auto only) { return only.setlists(); });
tempo::wpi::TempoAutos::chooser([](auto only) { return only.composers(); });
tempo::wpi::TempoAutos::chooser([](auto only) { return only.setlists().named("Comp.*"); });

named takes a regular expression that has to match the whole name.

AdvantageKit

AdvantageKit’s LoggedDashboardChooser copies the options when it’s built and keeps track of the selection itself. Build it after all the autos exist and give Tempo the selection with prePlan:

Java
import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;

// Constructor, after the autos exist. autos is a LoggedDashboardChooser<Auto> field.
autos = new LoggedDashboardChooser<>("Auto", TempoAutos.chooser());
TempoAutos.prePlan(autos::get);

// autonomousInit(). auto is the field that teleopInit() cancels, as in the first example.
auto = autos.get();
if (auto != null) auto.schedule();

Building your own chooser

TempoAutos.populate(autos) adds every named auto to a chooser of commands you built, so your other autos can go on the same chooser. Tempo plans the picked auto while the robot is disabled, and a pick that isn’t a Tempo auto plans nothing. Autos built later join the chooser.

Java
import com.tempo.TempoAutos;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;

SendableChooser<Command> autos = new SendableChooser<>();
autos.setDefaultOption("Do nothing", Commands.none());
TempoAutos.populate(autos);
SmartDashboard.putData("Auto", autos);
Python
import commands2
from tempo import TempoAutos
from wpilib import SendableChooser, SmartDashboard

self.autos = SendableChooser()
self.autos.setDefaultOption("Do nothing", commands2.cmd.none())
TempoAutos.populate(self.autos)
SmartDashboard.putData("Auto", self.autos)
C++
#include <frc/smartdashboard/SendableChooser.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <frc2/command/Commands.h>
#include <tempo/wpi/TempoAutos.h>

// members: frc::SendableChooser<frc2::Command*> autos_;
//          frc2::CommandPtr doNothing_ = frc2::cmd::None();
autos_.SetDefaultOption("Do nothing", doNothing_.get());
tempo::wpi::TempoAutos::populate(autos_);
frc::SmartDashboard::PutData("Auto", &autos_);

To make a Tempo auto the default, call setDefaultOption (SetDefaultOption in C++) with the auto’s name before populate. populate replaces the command under that name with the auto’s own, so the command you pass is only a placeholder, like Commands.none() (commands2.cmd.none() in Python, nullptr in C++). A default set after populate replaces the auto’s command, and the auto isn’t pre-planned.

On WPILib 2027 alpha-7 and beyond the chooser is a Selectable, and populate takes that too. It adds routes, Setlists and calibration routines. Any other Auto you registered isn’t a command, so add that one yourself.

AdvantageKit’s LoggedDashboardChooser works with the two-argument form:

Java
autos = new LoggedDashboardChooser<>("Auto");
TempoAutos.populate(autos::addOption, autos::get);

TempoAutos.names(), TempoAutos.get(name) and TempoAutos.all() return the registered autos for a chooser you fill yourself.

In C++ every TempoAutos call except chooser and populate is on tempo::TempoAutos, in <tempo/TempoAutos.h>. chooser and populate are on tempo::wpi::TempoAutos.

If you fill it yourself, there are two ways to get your chooser’s selection planned while the robot is disabled:

  • Pass the selection to TempoAutos.prePlan(supplier) (pre_plan in Python and C++) once. Tempo reads the supplier on the disabled loop and plans what it returns. TempoAutos.selected() returns the auto being planned.
  • Call warmup() on the selected auto from disabledPeriodic(), as in Warm up while disabled.

If your chooser holds commands made with a route’s or Setlist’s command(), give prePlan the route or Setlist behind the picked command. The command then starts on the plans made for it.

Anything that implements Auto, such as a wrapped command from another library, can be registered and listed. Nothing is planned for it while disabled.

Names and registration

Build each auto once and keep it in a field. Build it after Tempo.configure(...), because Composer.startAt (start_at in Python and C++) throws [Tempo] no config is applied yet; ... before that.

A Java field initializer that builds a route runs before the constructor and fails at startup this way.

If an auto is built again under a name that’s already taken, for example a Setlist made in a method that runs on every call, the two are compared. When they have the same steps and routes and their hooks are the same objects, the new copy is dropped and the first one keeps the name. A command made again is a new object, so the second build counts as a different auto.

Two different autos with one name are an error before Tempo has seen the robot enabled, which is normally robot init. After that the clash is printed to the console once for that name. The first auto keeps the name and its chooser entry, and the new one still runs when it’s scheduled. Registration has the details.

TempoAutos.register(auto) (register_auto in C++) registers an auto under its own name, and register("Name", auto) registers it under a different one. An unnamed route or Setlist has to be registered with a name to be listed.

TempoAutos.autoRegister(false) (auto_register in Python and C++) turns off self-registration and removes every auto that registered itself. Autos registered by hand with register stay.

Once a chooser lists a self-registered auto, turning self-registration off throws and so does renaming a listed auto with register. Name the autos and turn self-registration off before you build a chooser. The TempoAutos reference has every call and error message.

If it fails…

The chooser shows no autos Troubleshooting →

Only named autos are listed. Make each auto once with Setlist.named(...) or Composer.named(...) and keep it in a field.

Building the chooser throws on a name Above → [Tempo] two different autos are named "Two Piece"; build it once or rename one

Two autos with different steps, routes or hooks share a name. Build the auto once and keep it in a field, or rename one.

The console says the first auto keeps the name Above → [Tempo] two different autos are named "Two Piece"; the first one keeps the name. Build the auto once or rename one

A named auto was built again after robot init, with a new command or lambda. The chooser still lists the first one. Build the auto once and keep it in a field.

Turning self-registration off throws Above → [Tempo] auto registration was turned off after a chooser was built; turn it off before building one

Turn self-registration off before the first chooser is built.

esc

Loading search...