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

3.3 Speed & arrivals

speed(...) sets how fast the robot drives to a waypoint, and arrival(...) sets whether it drives through the waypoint, stops, or stops and pauses.

In this route the robot drives to scoringPose at CAREFUL, stops while scoreCommand runs, then waits another 0.3 s before leaving. The other legs drive at FULL.

Java
import static edu.wpi.first.units.Units.Seconds;

Composer.startAt(start)
    .originAlliance(Alliance.BLUE)
    .to(midfield)                     // FULL and THROUGH, the defaults
    .speed(Speed.CAREFUL)
    .to(scoringPose)                  // this leg drives at CAREFUL
        .arrival(Arrival.pause(Seconds.of(0.3)))
        .runAfter(scoreCommand)
    .speed(Speed.FULL)
    .to(intakeStation)
        .arrival(Arrival.STOP);
Python
(Composer.start_at(start)
    .origin_alliance(Alliance.BLUE)
    .to(midfield)                     # FULL and THROUGH, the defaults
    .speed(Speed.CAREFUL)
    .to(scoring_pose)                 # this leg drives at CAREFUL
        .arrival(Arrival.pause(0.3))
        .run_after(score_command)
    .speed(Speed.FULL)
    .to(intake_station)
        .arrival(Arrival.STOP))
C++
// score_ is a stored frc2::CommandPtr.
tempo::Composer::start_at(START)
    .origin_alliance(tempo::Alliance::Blue)
    .to(MIDFIELD)                     // Full and Through, the defaults
    .speed(tempo::Speed::Careful)
    .to(SCORING_POSE)                 // this leg drives at Careful
        .arrival(tempo::Arrival::pause(0.3))
        .run_after(score_.get())
    .speed(tempo::Speed::Full)
    .to(INTAKE_STATION)
        .arrival(tempo::Arrival::Stop());

Put speed(...) and limits(...) before the to(...) they apply to. Put arrival(...) after the to(...) whose waypoint it describes, or before the first to(...) to set it for every waypoint. All three stay in effect for later legs until you change them. In this route the pause would carry over to the station waypoint if it didn’t set Arrival.STOP.

Speed levels

The levels are FULL, CAREFUL, HALF and CRAWL, and FULL is the default. HALF and CRAWL are 50% and 25% of every FULL limit, including the turning limits. Speed levels has what CAREFUL uses.

If the wheels slip or short legs don’t reach their planned speed, try a slower level or lower limits(...) before raising tracking gains.

Custom limits

limits(...) sets a leg’s limits as numbers:

Java
// 3.5 m/s, 4.0 m/s^2, 6.0 m/s^2 centripetal from the next leg on.
route.limits(3.5, 4.0, 6.0)
    .to(scoringPose)
    // Also cap turning at 3 rad/s and 6 rad/s^2.
    .limits(3.5, 4.0, 6.0, 3.0, 6.0)
    .to(intakeStation);
Python
# 3.5 m/s, 4.0 m/s^2, 6.0 m/s^2 centripetal from the next leg on.
(route.limits(3.5, 4.0, 6.0)
    .to(scoring_pose)
    # Also cap turning at 3 rad/s and 6 rad/s^2.
    .limits(3.5, 4.0, 6.0, 3.0, 6.0)
    .to(intake_station))
C++
// 3.5 m/s, 4.0 m/s^2, 6.0 m/s^2 centripetal from the next leg on.
route.limits(3.5, 4.0, 6.0)
    .to(SCORING_POSE)
    // Also cap turning at 3 rad/s and 6 rad/s^2.
    .limits(3.5, 4.0, 6.0, 3.0, 6.0)
    .to(INTAKE_STATION);

A value above the robot’s Speed.FULL limit is lowered to it. The centripetal limit sets how fast the robot can go around a curve, so lower it if the robot slides sideways in turns. The two turning limits are optional. They can only lower the robot’s maxAngularVelocity and maxAngularAcceleration, set in LimitsConfigs.

These limits bound the plan. While feedback corrects the robot, the command can ask for more acceleration and a faster turn than the plan has (planning limits and commands).

limits(TrajectoryConstraints) also sets start and end velocities and a cap on how fast the modules steer (TrajectoryConstraints).

Arrivals

  • Arrival.THROUGH is the default. The robot drives through the waypoint at up to the lower of the two legs’ top speeds.
  • Arrival.through(f) drives through at no more than f times that speed, with f above 0 and up to 1.
  • Arrival.STOP slows to a stop at the waypoint.
  • Arrival.pause(t) stops and holds still for t seconds before the next leg.

C++ spells them Arrival::Through(), Arrival::through(f), Arrival::Stop() and Arrival::pause(t).

The Arrival reference has the details.

When Tempo plans the route, it prints a line for each through that may change nothing or carries no speed. The first kind means the leg before the waypoint is too short to reach the carried speed. The second kind can only print where the corner turns 90 degrees or more, and it says why the robot stops there:

  • the corner reverses the robot’s travel
  • the corner is beside a leg with an aimTarget, so it isn’t rounded
  • rounding it is no faster than stopping there
  • no rounded path clears the field

Stop before a command that needs the robot still, and at a sharp heading change. A STOP leg ends once the robot would come to rest inside the tolerance, which can be a moment before it’s still. If a command needs the robot motionless, add a waitUntil with a check that reads the drivetrain’s measured speed.

A runAfter command also runs when the leg ends outside its tolerance, but not when the leg fails, for example by giveUpAfter or a stall.

Arrival tolerance

arriveWithin sets how close to the waypoint the robot has to be for one leg to count as arrived. Other legs use the tolerance set with TempoConfig.withTolerance(...), which is 5 cm and 3 degrees unless changed.

Java
import static edu.wpi.first.units.Units.Degrees;
import static edu.wpi.first.units.Units.Meters;

route.to(intakeStation)
    .arriveWithin(Meters.of(0.02), Degrees.of(1.5));
Python
import math

route.to(intake_station).arrive_within(0.02, math.radians(1.5))
C++
#include <numbers>

route.to(INTAKE_STATION)
    .arrive_within(0.02, 1.5 * std::numbers::pi / 180.0);

Java takes Distance and Angle.

Python and C++ take meters and radians.

A robot that stays outside the tolerance settles, stalls or gives up (Missed arrivals).

In a Setlist, the last leg’s tolerance is also what the robot’s pose is compared with before the next route. Outside it, the robot makes a connecting drive to the next route’s start first.

Which legs share a plan

Consecutive THROUGH legs are planned together as one plan. Inside one plan, the speed at a waypoint is what the path’s shape and the limits allow, capped by a through(f) fraction, and a sharp corner there is driven slowly. Legs are planned separately when any of these is true:

  • the arrival between them is STOP or pause(...)
  • the first leg has a runAfter or a waitUntil, or the second a runBefore (hooks)
  • either leg has one of the failure calls endWhen, giveUpAfter or runOnFailure
  • either leg has a stayWithin, an aimTarget, an arriveWith, a bias, a Rotation Lock, its own arriveWithin or a terrain crossing
  • either leg uses a custom control
  • the legs have different rotation (for example, a waypoint heading turns the robot on one of them), limits, follower, track width, gains, replanning or extension

A THROUGH waypoint between two separate plans is still driven through, at the carry speed.

The robot stops at a THROUGH waypoint between two plans in these cases:

  • the first leg has a runAfter, a waitUntil or an arriveWith, or the second a runBefore
  • either leg has a terrain crossing whose target has a heading
  • the corner reverses the robot’s travel, rounding it is no faster than stopping there, or no rounded path clears the field (Arrivals)

With limits set higher than the robot reaches, it can’t hold the curve through a rounded corner, falls off the path and replans. Run the calibration routines and plan with the limits they measure.

preplanAhead sets how many later plans a route keeps planned in the background while it drives. Legs planned together count as one plan.

If it fails…

A through arrival still stops the robot Above → [Tempo] arrival(through) carries no speed into leg 3: the corner at leg 2 turns 120 degrees, ...

The line can only print where the corner turns 90 degrees or more, and the rest of it gives the reason the robot stops there. Arrivals lists the reasons. Make the corner shallower or accept the stop.

A through fraction has no effect Above → [Tempo] arrival(through) may shape nothing at leg 3: leg 2 is ...

The leg before the waypoint is too short to reach the carried speed. Give the leg more room or lower the fraction.

esc

Loading search...