4.7 Measured limits
MeasuredConfigs holds limits measured on the robot. Pass it to
withMeasured(...). Running the calibration autos is covered on
Calibrate the drivetrain.
MeasuredConfigs
import com.tempo.config.MeasuredConfigs;
MeasuredConfigs measured = new MeasuredConfigs()
.maxVelocity(3.943)
.maxAcceleration(8.101)
.accelerationAt(0.952, 8.101)
.accelerationAt(2.230, 5.884)
.maxDeceleration(8.919)
.maxAngularVelocity(11.0)
.maxAngularAcceleration(37.117)
.lag(0.078)
.steeringLag(0.055)
.turningAt(0.639, 9.126, 34.485)
.turningAt(1.859, 5.738, 16.613);from tempo import MeasuredConfigs
measured = (MeasuredConfigs()
.max_velocity(3.943) # m/s
.max_acceleration(8.101) # m/s^2
.acceleration_at(0.952, 8.101) # m/s, m/s^2
.acceleration_at(2.230, 5.884)
.max_deceleration(8.919) # m/s^2
.max_angular_velocity(11.0) # rad/s
.max_angular_acceleration(37.117) # rad/s^2
.lag(0.078) # s
.steering_lag(0.055) # s
.turning_at(0.639, 9.126, 34.485) # m/s, rad/s, rad/s^2
.turning_at(1.859, 5.738, 16.613))auto measured = tempo::MeasuredConfigs{}
.max_velocity(3.943) // m/s
.max_acceleration(8.101) // m/s^2
.acceleration_at(0.952, 8.101) // m/s, m/s^2
.acceleration_at(2.230, 5.884)
.max_deceleration(8.919) // m/s^2
.max_angular_velocity(11.0) // rad/s
.max_angular_acceleration(37.117) // rad/s^2
.lag(0.078) // s
.steering_lag(0.055) // s
.turning_at(0.639, 9.126, 34.485) // m/s, rad/s, rad/s^2
.turning_at(1.859, 5.738, 16.613);| Java | Python / C++ | Unit | Effect |
|---|---|---|---|
new MeasuredConfigs() | MeasuredConfigs(), tempo::MeasuredConfigs{} | No measured limits. Add each below | |
saved() | saved() | The robot’s saved calibration, then deploy/tempo/calibration.json, else none. A robot file that can’t be read is skipped with a warning, and a deploy copy that can’t be read throws | |
fromFile(Path), fromJson(String) | from_file(path), from_json(text) | A saved result, or its measured block | |
maxVelocity(double) | max_velocity(v) | m/s | Top speed in every speed level |
maxAcceleration(double) | max_acceleration(a) | m/s^2 | Acceleration. Routes plan with the smaller of it and the deceleration |
accelerationAt(speed, acceleration) | acceleration_at(speed, acceleration) | m/s, m/s^2 | One point of the acceleration curve |
maxDeceleration(double) | max_deceleration(a) | m/s^2 | Braking deceleration |
maxAngularVelocity(double) | max_angular_velocity(w) | rad/s | Angular velocity limit |
maxAngularAcceleration(double) | max_angular_acceleration(a) | rad/s^2 | Angular acceleration limit |
lag(double) | lag(s) | s | Follower latency, unless withLag states one |
steeringLag(double) | steering_lag(s) | s | On a swerve drive, how long the direction of travel takes to follow a command. When the follower latency is the measured lag, the route’s direction of travel is commanded this much ahead |
turningAt(speed, rate, acceleration) | turning_at(speed, rate, acceleration) | m/s, rad/s, rad/s^2 | One point of the turning headroom |
savedFile() | saved_file() | Where a calibration saves with saveToRobot(): tempo/calibration.json under the operating directory (/home/lvuser on a roboRIO, /home/systemcore on a SystemCore) |
Each value is a plain SI number or a WPILib unit, such as
maxVelocity(MetersPerSecond.of(3.9)) in Java or max_velocity(3.9_mps) in C++. A measured
wheel radius goes on the module with
wheelRadius(...), and the report prints it on
its own line. Every value must be finite and positive, with three exceptions:
- The lag and the steering lag may be zero.
- A turning point’s speed and rate may be zero.
- An acceleration point’s speed and acceleration may be zero, but the slowest point’s acceleration must be above zero.
A measured value replaces the one Tempo derives from the motor model in every speed level,
and it’s a ceiling. A limit stated in LimitsConfigs can lower it
but can’t raise it. Each leg’s planned speed and acceleration stay within the measured
Speed.FULL.
Acceleration curve
The accelerationAt(speed, acceleration) points make a curve of acceleration against speed.
While the robot speeds up, each leg’s acceleration stays under this curve. The points read back with
acceleration() in Java and C++ and acceleration_points in Python.
- The curve is linear between points. Below the slowest point it uses that point’s value, and above the fastest point it uses the fastest point’s.
- A point higher than a slower one is lowered to it.
- Without
maxAcceleration, the slowest point’s acceleration is the acceleration from rest. - A
maxAccelerationwithout a curve keeps the motor model’s curve, scaled so that it starts at the measured value (within wheel grip). Without a motor model it’s a flat limit.
Turning points
Each turningAt(speed, rate, acceleration) point is the turn rate and the angular
acceleration the robot reached while driving at speed.
On a swerve drive, Tempo fits a straight line through the points’ rates, with the
in-place turn rate (the measured maxAngularVelocity) as the point at rest. A turning
leg’s turn rate stays under that line at the speed it drives. The fit takes at least two
points at different speeds, with the rate falling as the speed rises.
The points’ angular accelerations, with the measured maxAngularAcceleration at rest, limit each turn’s
angular acceleration. The limit is read at the fastest speed the leg drives through that
turn.
- The limit is linear between points. Below the slowest point it’s that point’s value.
- Beyond the fastest point it follows the line through the last two points, but never goes below a tenth of the fastest point’s value.
Without turning points, a measured maxAngularAcceleration falls with speed in step with
the acceleration curve. At a speed where the curve allows half the planning acceleration,
a turn gets half the measured angular acceleration. An angular acceleration stated in
LimitsConfigs stays flat.
Tempo prints a warning when the measured top speed or acceleration is more than 25% from what the motor model gives, or the measured wheel radius more than 2% from the module’s.
TempoCalibration
Each TempoCalibration method in the table below makes a new calibration auto (a
TempoCalibration.Routine in Java and C++), and the auto registers itself in TempoAutos
under its chooser name.
| Java | Python | C++ | Effect |
|---|---|---|---|
all(), translation(), lag(), turning(), rotation(), wheelRadius() | snake_case | snake_case | One routine, or all in that order, as an Auto |
topSpeed() | top_speed() | top_speed() | One drive held until its speed settles, not part of all(). With too little floor the result’s JSON holds a lower bound (topSpeedAtLeastMps) and the floor needed (floorNeededM) |
On a swerve drive lag() ends with a weave that reads the steering lag. The weave asks
for no more acceleration than the drivetrain has, or than the stated limit with
respectLimits(), and it drives slower and swings slower to fit.
The options chain on the auto.
| Java | Python | C++ | Effect |
|---|---|---|---|
space(Distance), space(double) | space(meters) | space(meters) | Clear floor in a straight line. The robot starts in the middle. 3 m by default |
modulePositions(Supplier<SwerveModulePosition[]>) | module_positions(fn) | module_positions(fn) | Swerve module positions, for the wheel radius routine. Python takes anything with a distance in meters, and C++ takes any range of values with a distance |
wheelDistances(Supplier<double[]>) | wheel_distances(fn) | wheel_distances(std::function<std::vector<double>()>) | Drive wheel distances in meters, for the wheel radius routine |
wheelPositions(Supplier<double[]>) | wheel_positions(fn) | wheel_positions(std::function<std::vector<double>()>) | Drive wheel rotations in radians, for the wheel radius routine |
turningFractions(double...) | turning_fractions(*f) | turning_fractions({...}) | Fractions of the top speed the turning routine drives at. The default is 0.25, 0.5, 0.75 and 1 |
saveToRobot(), saveToRobot(boolean) | save_to_robot(enabled=True) | save_to_robot(bool = true) | Merge each run’s readings into the robot’s calibration file, which saved() loads. The report’s line then holds every reading in it. The command lag and the steering lag are saved as a pair, and a run that reads the command lag replaces both. Off by default |
respectLimits(), respectLimits(boolean) | respect_limits(enabled=True) | respect_limits(bool = true) | Keep every command within the configured limits. Readings at them are marked capped |
command() | command() | tempo::wpi::command(routine) | The auto’s command, for a chooser of commands or a button |
name() | name() | name() | The chooser name, such as “Tempo Calibration: All” |
result() | result() | result() | The auto’s latest TempoCalibrationResult: null in Java, None in Python, an empty std::optional in C++ before a run |
TempoCalibrationResult gives capped, the readings at a configured limit by their saved
key. Its extrapolatedAboveMps (extrapolated_above_mps) is the speed above which the
acceleration curve and the top speed were estimated. It’s NaN when the drives reached the top
speed.