4.6 Trajectory limits
LimitsConfigs caps the speeds and accelerations Tempo plans with. Pass it to
withLimits(...). Each value also takes a supplier of a plain SI number (a Java
DoubleSupplier like a LoggedTunableNumber, or a Python or C++ callable), and the next
route Tempo builds uses the new value (Live tuning).
LimitsConfigs
import static edu.wpi.first.units.Units.MetersPerSecond;
import static edu.wpi.first.units.Units.MetersPerSecondPerSecond;
import com.tempo.config.LimitsConfigs;
LimitsConfigs limits = new LimitsConfigs()
.maxVelocity(MetersPerSecond.of(4.5))
.maxAcceleration(MetersPerSecondPerSecond.of(3.0))
.maxCentripetal(MetersPerSecondPerSecond.of(5.0));from tempo import LimitsConfigs
limits = (LimitsConfigs()
.max_velocity(4.5) # m/s
.max_acceleration(3.0) # m/s^2
.max_centripetal(5.0)) # m/s^2auto limits = tempo::LimitsConfigs{}
.max_velocity(4.5)
.max_acceleration(3.0)
.max_centripetal(5.0);| Java | Python / C++ | Unit | Default |
|---|---|---|---|
maxVelocity(mps) | max_velocity(mps) | m/s | The drivetrain’s derived value. On mecanum it’s required |
maxAcceleration(mps2) | max_acceleration(mps2) | m/s^2 | The drivetrain’s derived value. On mecanum it’s required |
maxCentripetal(mps2) | max_centripetal(mps2) | m/s^2 | The acceleration cap when this group sets one, else the drivetrain’s |
maxAngularVelocity(radps) | max_angular_velocity(radps) | rad/s | The drivetrain cap. On swerve that’s the Speed.FULL velocity over the largest module offset |
maxAngularAcceleration(radps2) | max_angular_acceleration(radps2) | rad/s^2 | The drivetrain cap. On swerve that’s the Speed.FULL acceleration times the average offset, over the bumper outline’s inertia per kilogram. Without module offsets it’s the Speed.FULL acceleration over the footprint radius |
LimitsConfigs.of(TrajectoryConstraints) | LimitsConfigs.of(constraints) | Starts the group from a TrajectoryConstraints, which also holds start speed, end speed and the steer-rate cap |
Each value is a plain SI number or a WPILib unit.
On swerve and tank drives, Tempo derives the limits from the drive motors in the module or
tank config when there’s no withLimits. Setting only maxVelocity keeps the derived
acceleration and cornering limits. Each value has a ceiling:
- The ceilings are what the hardware allows with no loss: the wheel free speed, the wheel force at the drive current limit divided by the mass (no more than grip, COF x 9.81), and grip for cornering (Limits set above these).
- A value set here replaces the derived estimate, up to its ceiling. A value above the ceiling plans at the ceiling.
- A drive’s supply current limit lowers the acceleration planned at speed and leaves the ceilings as they are.
- With measured limits, the measured values are the ceilings, and a value set here only lowers them.
A mecanum config doesn’t describe its motors, so withLimits is required with both
maxVelocity and maxAcceleration, and the values are used as set.
On every drivetrain:
- The centripetal cap bounds cornering speed at
v <= sqrt(centripetal / curvature). - Angular values are nonnegative, and zero inherits the drivetrain cap. On a swerve drive a value above the drivetrain’s ceiling, including infinity, plans at the ceiling. A negative or NaN value throws.
- A max angular velocity does nothing on a differential drive.
- In Java and C++,
TrajectoryConstraints.defaults()is 5 m/s velocity, 6 m/s^2 acceleration and 8.1 m/s^2 centripetal. Python has nodefaults(). - When a limit here changes, a leg written with
speed(...)takes the new value the next time Tempo plans its route. A leg with its ownlimits(...)keeps its numbers, and the robot’s limits at that time still cap them.
A leg’s own limits(...) only lower the robot’s. A velocity, acceleration or
centripetal value above the robot’s Speed.FULL
is lowered to Speed.FULL’s value, and the route prints a line naming the first such leg
when it freezes. Angular values work the same way.