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.
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);(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))// 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:
// 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);# 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))// 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.THROUGHis 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 thanftimes that speed, withfabove 0 and up to 1.Arrival.STOPslows to a stop at the waypoint.Arrival.pause(t)stops and holds still fortseconds 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.
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));import math
route.to(intake_station).arrive_within(0.02, math.radians(1.5))#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
STOPorpause(...) - the first leg has a
runAfteror awaitUntil, or the second arunBefore(hooks) - either leg has one of the failure calls
endWhen,giveUpAfterorrunOnFailure - either leg has a
stayWithin, anaimTarget, anarriveWith, a bias, a Rotation Lock, its ownarriveWithinor 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, awaitUntilor anarriveWith, or the second arunBefore - 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…
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.
The leg before the waypoint is too short to reach the carried speed. Give the leg more room or lower the fraction.