A naive autonomous program that runs the robot at full throttle until it nears the end of the path will overshoot: the drivetrain cannot decelerate fast enough to stop at the target. A trapezoidal velocity profile solves this by pre-computing a speed schedule — accelerate from rest, cruise at maximum speed when possible, then brake smoothly to a stop — all while respecting how fast the robot can accelerate and decelerate given its drivetrain characteristics. Odyssey’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/saquer916/odyssey/llms.txt
Use this file to discover all available pages before exploring further.
VelocityProfile extends the classic trapezoid with a third constraint: centripetal acceleration. On tight curves, even a modest speed can demand more lateral force than the wheels can generate, causing the robot to slide off the path. The profile caps speed at every point where curvature is high enough to matter, then reapplies the forward and backward passes so the trapezoid remains physically achievable around that speed dip.
Three-pass algorithm
VelocityProfile discretizes the path into samples separated by step millimetres and populates a velocities[] array in three sequential passes.
Pass 1 — Curvature cap
For every sample index When κ is below
i, query the path curvature κ at distances[i] and compute the maximum speed that keeps centripetal acceleration within maxCentripetalAccel:1e-4 (effectively a straight line), curveLimit is set to maxVelocity so the centripetal constraint has no effect on near-straight segments.Pass 2 — Forward acceleration propagation
Starting from
velocities[0] = 0 (robot starts from rest), sweep forward and ensure no sample is faster than the robot could reach from the previous sample under maxAcceleration:Constructor
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to profile — its total length and curvature are queried during construction |
maxVelocity | double | Hard speed ceiling in mm/s |
maxAcceleration | double | Maximum forward acceleration in mm/s² |
maxBrake | double | Maximum braking deceleration in mm/s² |
maxCentripetalAccel | double | Maximum centripetal (lateral) acceleration in mm/s² |
step | double | Distance between profile samples in mm |
The
step parameter controls a resolution–performance trade-off. A smaller step (e.g. 1.0 mm) samples curvature more densely, catching narrow tight bends that a coarser grid might underestimate — but it increases both the construction time and the size of the velocities[] and distances[] arrays. A value of 5.0 mm works well for most FTC paths. Only go below 2.0 mm if your path has very sharp inflection points that noticeably affect robot tracking.Querying the profile at runtime
getTargetVelocity(double distance)
Returns the target speed in mm/s at the given arc-length distance from path start. Rather than returning the raw sampled value, Odyssey performs v²-interpolation (quadratic interpolation on squared velocity) between the two surrounding samples for a smooth output:
v would underestimate speed in the middle of an acceleration phase, while interpolating on v² matches the physics exactly.
