4.14 Speed
speed(level) sets a leg’s limits from the robot’s hardware and limits(...)
sets them as numbers. Both apply to the next to(...) and every later leg until
changed, and the later call replaces the earlier one. Without either one every leg
runs at Speed.FULL. In this example the legs to a and b use the numbers, and
the leg to c runs at CAREFUL without them.
import com.tempo.Speed;
var route = Composer.startAt(start)
.limits(3.5, 4.0, 6.0)
.to(a)
.to(b)
.speed(Speed.CAREFUL)
.to(c);from tempo import Speed
route = (Composer.start_at(start)
.limits(3.5, 4.0, 6.0)
.to(a)
.to(b)
.speed(Speed.CAREFUL)
.to(c))#include <tempo/Speed.h>
auto route = tempo::Composer::start_at(start)
.limits(3.5, 4.0, 6.0)
.to(a)
.to(b)
.speed(tempo::Speed::Careful)
.to(c);Speed levels
C++ spells them Full, Careful, Half and Crawl.
| Level | With a drivetrain model: rated velocity / drive current / grip | Without one: velocity / acceleration / centripetal |
|---|---|---|
FULL | 1.00 / 1.00 / 1.00 | 1.00 / 1.00 / 1.00 |
CAREFUL | 0.95 / 0.85 / 0.90 | 0.80 / 0.50 / 0.71 |
HALF | 0.50 of every FULL limit | 0.50 / 0.50 / 0.50 |
CRAWL | 0.25 of every FULL limit | 0.25 / 0.25 / 0.25 |
A drivetrain model is a swerve module or differential configuration with motor,
current limit and wheel data. With one, FULL and CAREFUL each take the
table’s share of the rated velocity, the drive current limit and the grip, and
the limits are worked out from those
(Limits Tempo derives). Limits
set in the config stay ceilings.
A level whose share of the current can’t overcome the drivetrain’s losses throws
Drive current budget cannot overcome calibrated drivetrain losses at 12 V.
HALF and CRAWL scale every FULL limit, the turn limits included. They have
no current share of their own, so they work wherever FULL does.
speed(level) is worked out again each time Tempo builds the route, so it
follows a live speed limit in the config. A slower level doesn’t change the
arrival tolerance.
| Member | Returns |
|---|---|
constraints() | The level’s limits for the active config. Throws before Tempo.configure(...) |
of(config) | The level’s limits for a TempoConfig |
of(ceiling) | The level’s fractions applied to a TrajectoryConstraints |
velocityFraction(), accelerationFraction() | The level’s fractions |
Python’s of(...) takes either a TempoConfig or a TrajectoryConstraints, and
velocity_fraction and acceleration_fraction are properties.
C++ resolves with tempo::speed_of(level, config) or
tempo::speed_of(level, ceiling).
TrajectoryConstraints
import com.tempo.TrajectoryConstraints;
var limits = new TrajectoryConstraints(3.5, 4.0, 6.0, 0.0, 0.0);
var turnLimited = new TrajectoryConstraints(3.5, 4.0, 6.0, 0.0, 0.0, 12.0, 4.0, 8.0);
route.limits(turnLimited);from tempo import TrajectoryConstraints
limits = TrajectoryConstraints(3.5, 4.0, 6.0, 0.0, 0.0)
turn_limited = TrajectoryConstraints(3.5, 4.0, 6.0, 0.0, 0.0, 12.0, 4.0, 8.0)
route.limits(turn_limited)tempo::TrajectoryConstraints limits{3.5, 4.0, 6.0, 0.0, 0.0};
tempo::TrajectoryConstraints turn_limited{3.5, 4.0, 6.0, 0.0, 0.0, 12.0, 4.0, 8.0};
route.limits(turn_limited);| Position | Field | Units | Rule |
|---|---|---|---|
| 1 | Maximum velocity | m/s | finite, positive |
| 2 | Maximum acceleration | m/s^2 | finite, positive |
| 3 | Maximum centripetal acceleration | m/s^2 | finite, positive |
| 4 | Start velocity | m/s | finite, nonnegative |
| 5 | End velocity | m/s | finite, nonnegative |
| 6, optional | Module steer rate. 0 means no cap | rad/s | finite, nonnegative |
| 7, optional | Chassis angular velocity. 0 uses the robot cap | rad/s | finite, nonnegative |
| 8, optional | Chassis angular acceleration. 0 uses the robot cap | rad/s^2 | finite, nonnegative |
Java has five-, six- and eight-argument constructors.
Python and C++ default omitted trailing fields to 0.
In Java and C++, TrajectoryConstraints.defaults()
(TrajectoryConstraints::defaults()) is 5 m/s velocity, 6 m/s^2 acceleration and
8.1 m/s^2 centripetal with every other field 0.
Python has no defaults().
The start velocity is used on the route’s first leg and the end velocity on its
last. Between legs the arrival sets the speed. The robot is at rest at a STOP or
pause, and at the carry speed at a through
waypoint. An end velocity above zero on the arriving leg caps the carry speed. In
a Setlist, a route entered or left moving uses the
join speed at that end.
| Composer form | Sets |
|---|---|
limits(v, a, c) | Fields 1 to 3. Start and end velocities 0, no steer cap, robot angular caps |
limits(v, a, c, omega, alpha) | Fields 1 to 3, then chassis angular velocity (rad/s) and acceleration (rad/s^2), fields 7 and 8, as arguments 4 and 5. The start and end velocities stay 0 |
limits(constraints) | Every field |
Fields 1 to 3 can only lower the robot’s Speed.FULL limits. A larger value is
lowered to Speed.FULL’s, and the route prints a line naming it the first time it
freezes. Fields 7 and 8 can only lower the robot’s turn caps.
An invalid value throws IllegalArgumentException, ValueError or
std::invalid_argument naming the field. Java also checks in the constructor,
and Python and C++ check when limits(...) receives it.