4.20 Control
Control picks the controller that tracks the planned path.
Composer.control(...) applies to the leg it follows and every later leg until
another control(...) replaces it. In this example the leg to pickup runs
follower, your own PathFollower, and
Control.standard() puts the leg to score back on the built-in follower, which
is the default. Tuning is on Tune path following.
import com.tempo.Composer;
import com.tempo.Control;
var route = Composer.startAt(start)
.to(pickup)
.control(Control.custom(follower))
.to(score)
.control(Control.standard());from tempo import Composer, Control
route = (Composer.start_at(start)
.to(pickup)
.control(Control.custom(follower))
.to(score)
.control(Control.standard()))#include <tempo/Composer.h>
#include <tempo/Control.h>
auto route = tempo::Composer::start_at(start)
.to(pickup)
.control(tempo::Control::custom(follower))
.to(score)
.control(tempo::Control::standard());Factories and modifier
| Java | Python and C++ | Behavior |
|---|---|---|
standard() | standard() | The built-in follower for the configured drivetrain (default) |
custom(follower) | custom(follower) | A PathFollower gets the planned pose and velocity and returns robot-relative speeds |
custom(factory) | Python custom(factory=...), C++ custom(factory) | A fresh controller for each driving leg and run |
thenFilter(op) | then_filter(op) | Changes the controller’s output |
A filter takes and returns WPILib ChassisSpeeds (ChassisVelocities on
2027). Filters run in the order they’re added and keep the controller under them.
Each method returns a new Control. A null or empty argument throws
(NullPointerException in Java, TypeError in Python, std::invalid_argument in C++).
Drivetrain resolution
standard() uses the follower for the configured drivetrain. Its gains come
from withPID and Composer.gains(...).
| Drivetrain | Follower |
|---|---|
| Swerve | A trajectory follower that tracks the planned pose for the current time, with feedforward plus PID |
| Mecanum | The same follower as swerve. The robot’s MecanumDriveKinematics turns its chassis speeds into wheel speeds |
Differential (withTank) | RAMSETE, the control law WPILib’s RamseteController uses. Heading follows the travel direction, forward or backward |
The track width comes from TankConfigs.trackWidth(...). A differential-drive
leg without one fails the freeze.
Java throws IllegalStateException, Python raises ValueError and C++ throws
std::logic_error:
Java: Control.standard() needs a differential drivetrain configured with TempoConfig.withTank(...), or an explicit track width
Python: Control.standard() needs a differential drivetrain configured with TempoConfig.with_tank(...), or an explicit track width
C++: Control::standard() needs a differential drivetrain configured with TempoConfig::with_tank(...), or an explicit track widthCustom controller and output
A custom controller gets a setpoint pose and a field-relative velocity (ControlContext), and the velocity it returns is robot-relative. Followers and filters run on the robot loop and must not block.
With a custom follower Tempo still plans the route and checks when each leg is
done, but it doesn’t hold the output of a custom controller or a filter to the
leg’s limits. If the controller has state, use the optional
initialize, reset and end methods.
A filter added with thenFilter keeps them.
Tempo calls Control.hook() (a property in Python) when a leg is about to drive,
and never during warm-up. Robot code doesn’t need to call it, and the name has
nothing to do with a route’s hooks. It returns the follower this Control holds,
or calls its factory for a new one. Standard control without a filter returns
null, None, or an empty callable in C++.