explainer
Trapezoidal velocity profiles: accelerate, cruise, and stop
Build a rest-to-rest motion for one linear joint. Derive triangular and trapezoidal velocity profiles, calculate braking distance, and inspect exact position, velocity and acceleration within explicit limits.
What you will learn
- Calculate the time needed to accelerate, cruise and brake along one axis.
- Decide whether a move reaches its speed limit before braking.
- Recover displacement from the signed area under a velocity graph.
- Evaluate position and velocity at any time without numerical integration.
- Explain the acceleration jumps and the scope of the minimum-time claim.
Before you start
A linear robot joint needs room to speed up and stop. A trapezoidal velocity profile allocates that room, then uses any remaining distance to cruise. A short move has no room for cruising, so its velocity graph becomes a triangle.
We will derive both profiles for one ideal prismatic joint. You can then calculate the duration and inspect any instant. The model also exposes acceleration jumps that a speed graph can hide.
Define the one-axis motion
Let x measure carriage position in metres along a fixed rail. Positive x points right. The carriage starts at x = 0 and ends at signed position D, with zero velocity at both ends.
Write L = |D| for the nonnegative travel length. For nonzero travel, let σ = sign(D) describe its direction. A negative destination reverses position, velocity and acceleration while preserving the phase durations.
The speed bound is |v| ≤ V, where V is positive and uses m/s. The acceleration bound is |a| ≤ A, where A is positive and uses m/s². We assume equal acceleration and braking limits, with no other motion constraints.
A rotary joint can use the same scalar reasoning with radians. Every quantity must use matching angular units. Our experiment uses a linear joint throughout.
Read distance from velocity area
Velocity is the derivative of position. Its signed area over time gives displacement. A curve below the time axis therefore gives negative displacement.
During acceleration, velocity rises linearly from zero to a peak speed v_peak. It stays at that peak during the cruise phase, then falls linearly to zero. The two triangles and the rectangle give:
L = ½v_peak t_a + v_peak t_c + ½v_peak t_a
L = v_peak(t_a + t_c)
Here t_a is the duration of each ramp and t_c is cruise duration. Total duration is T = 2t_a + t_c. The signed velocity area is σL = D.
This geometric check catches a common mistake: multiplying peak speed by total time overestimates travel. The carriage spends both ramps below its peak speed. MathWorks derives profile constraints from the same velocity-area relationship.
Reserve room to stop
At speed magnitude w, braking with acceleration magnitude A takes w/A seconds. The triangular velocity area during braking is:
d_stop = ½w(w/A) = w²/(2A)
This is the minimum stopping distance in the stated acceleration-only model. At 1 m/s with A = 1 m/s², braking needs 0.5 m. Reaching that speed from rest also needs 0.5 m.
The combined distance to reach speed V and stop is therefore V²/A. If the destination is closer, braking must begin below V. Real stopping also depends on delay, available braking force and physical tracking, which this formula leaves out.
Decide whether there is a cruise phase
For L greater than V²/A, the joint reaches V and cruises. Its acceleration time is V/A. Solve the velocity-area equation for the remaining cruise time.
For L below V²/A, the two ramps consume the whole move. With v_peak = At_a, the area becomes L = At_a². This gives t_a = √(L/A) and a peak speed below V.
Both cases share these formulas when L is positive:
t_a = min(V/A, √(L/A))
v_peak = At_a
t_c = max(0, L/v_peak − t_a)
T = 2t_a + t_c
At L = V²/A, the peak touches V for an instant. Cruise duration is exactly zero. We label this boundary “Triangular (at speed limit)” to distinguish it from a positive cruise interval.
For L = 0, there is no motion. Set all durations, position, velocity and acceleration to zero. Handle this case before dividing by v_peak.
Evaluate the motion in each phase
First compute a nonnegative traveled distance y(t); then set x(t) = σy(t). Let t_b = t_a + t_c mark the start of braking. For 0 ≤ t ≤ T, use:
Accelerating, 0 ≤ t < t_a:
y = ½At², ẏ = At
Cruising, t_a ≤ t < t_b:
y = ½At_a² + v_peak(t − t_a)
ẏ = v_peak
Braking, t_b ≤ t ≤ T:
y = L − ½A(T − t)²
ẏ = A(T − t)
The final formula works backward from the destination. It makes y(T) = L and ẏ(T) = 0 explicit. Position and velocity agree at both phase boundaries.
Inside the phases, signed acceleration is σA, 0, then −σA. Acceleration jumps at switches and where the moving segment meets stationary holds. At those instants, the velocity derivative has no single classical value.
The experiment reports the right-hand acceleration limit at the start and internal switches. At T it reports the left-hand limit from braking. The “Acceleration meaning” readout identifies these choices; stationary holds outside the moving segment have zero acceleration.
State the minimum-time result precisely
These triangular and trapezoidal profiles minimize duration for this scalar rest-to-rest problem with only the fixed V and A bounds. Velocity stays continuous and piecewise differentiable; acceleration can jump between segments. The claim assumes the ideal joint can follow the reference exactly.
To see why, consider any candidate duration T. In the destination direction, velocity cannot exceed At, because the move starts at rest. It also cannot exceed A(T − t), because it must finish at rest, or the speed limit V.
The largest possible forward velocity at each time is therefore min(At, V, A(T − t)). Its area bounds how far any admissible motion can travel in time T. Using that upper envelope gives the triangle or trapezoid and attains the bound.
Solving for the duration needed to cover L gives:
If L ≤ V²/A: T = 2√(L/A)
If L > V²/A: T = L/V + V/A
This proof covers one scalar coordinate. A coupled robot with a prescribed curved path and torque limits has a different optimization problem. Modern Robotics describes how those dynamic limits constrain path acceleration.
Work through a 2 m move
Choose D = 2 m, V = 1 m/s and A = 1 m/s². The threshold V²/A is 1 m, so this move has a cruise phase. Acceleration and braking each take 1 s, cruise takes 1 s, and total duration is 3 s.
Each ramp covers 0.5 m. The cruise covers the middle 1 m. Their areas add to the required 2 m.
At t = 0.75 s, the joint is still accelerating. Position is ½ × 1 × 0.75² = 0.28125 m, velocity is 0.75 m/s, and acceleration is 1 m/s². This is the experiment's initial instant.
At t = 2.5 s, only 0.5 s remains. Position is 2 − ½ × 0.5² = 1.875 m, and velocity is 0.5 m/s. The remaining 0.125 m equals its stopping distance, 0.5²/(2 × 1).
For a shorter D = 0.5 m, the profile becomes triangular. It reaches √0.5 ≈ 0.707107 m/s and finishes in √2 ≈ 1.414214 s. The speed bound stays at 1 m/s; the move simply never reaches it.
Change the travel and limits
Select “Short move” and watch the cruise disappear. Then select “Zero-cruise boundary” to see a triangular profile just touch the speed limit. “Negative travel” reflects the velocity curve below zero while keeping the duration unchanged.
The time control uses the elapsed fraction u = t/T. Changing a motion parameter keeps that fraction; choosing a preset returns it to 0.25. For zero travel, elapsed time remains zero for every fraction.
The velocity graph uses physical seconds and m/s. Its horizontal and vertical scales change with the chosen motion. Compare the labeled limits and durations before judging two curves by their drawn slopes.
At an internal switch, the readout chooses the phase on its right. Move to the final instant to see zero velocity alongside the braking segment's one-sided acceleration. A zero endpoint velocity alone says nothing about acceleration continuity.
Connect the reference to a real robot
The profile generates a desired position and velocity over time. A controller still needs measurements and actuator commands to track them. WPILib's profile documentation makes this connection by passing profile states to a separate controller.
Acceleration jumps imply an unbounded ideal jerk, so this model has no finite jerk guarantee. Flexible mechanisms can vibrate when commands change sharply. Modern Robotics introduces S-curve timing as a way to prescribe finite jerk segments and continuous acceleration.
For several joints, independent minimum-time profiles can finish at different times. Even synchronized endpoints do not establish a desired tool path. A common path time scaling coordinates progress, while the joint-to-tool velocity map explains the resulting Cartesian motion.
This distinction also matters when a learned model chooses robot targets. A model's endpoint prediction still needs motion generation and physical validation. Scalar speed and acceleration limits alone establish neither collision clearance nor adequate motor force.
Reproduce the profiles in Python
This standard-library example evaluates the same analytic phases. It prints each preset at one quarter of its duration, then checks the default braking instant. It uses floating-point arithmetic and rounds the displayed output to six decimal places.
from math import isfinite, sqrt
def profile(D, V, A, u):
if not all(isfinite(n) for n in (D, V, A, u)):
raise ValueError("Inputs must be finite")
if V <= 0 or A <= 0 or not 0 <= u <= 1:
raise ValueError("Use positive limits and 0 <= u <= 1")
L = abs(D)
if L == 0:
return (0.0,) * 8
direction = 1 if D > 0 else -1
ta = min(V / A, sqrt(L / A))
peak = A * ta
tc = max(0.0, L / peak - ta) if L > V * V / A else 0.0
T = 2 * ta + tc
t = u * T
if t < ta:
y, speed, acceleration = 0.5 * A * t * t, A * t, A
elif t < ta + tc:
y = 0.5 * A * ta * ta + peak * (t - ta)
speed, acceleration = peak, 0.0
else:
remaining = T - t
y = L - 0.5 * A * remaining * remaining
speed, acceleration = A * remaining, -A
x = D if u == 1 else direction * y
v, a = direction * speed, direction * acceleration
return T, ta, tc, peak, t, x, v, a
def f(value):
return f"{0.0 if abs(value) < 0.0000005 else value:.6f}"
for D in (2.0, 0.5, 1.0, -2.0, 0.0):
T, ta, tc, peak, t, x, v, a = profile(D, 1.0, 1.0, 0.25)
print(f"D={D:.2f}: T={f(T)} ta={f(ta)} tc={f(tc)} peak={f(peak)}")
print(f" t={f(t)} x={f(x)} v={f(v)} a={f(a)}")
*_, x, v, a = profile(2.0, 1.0, 1.0, 2.5 / 3.0)
print(f"Braking: x={f(x)} v={f(v)} a={f(a)} stop={f(v*v/2.0)}")
Output:
D=2.00: T=3.000000 ta=1.000000 tc=1.000000 peak=1.000000
t=0.750000 x=0.281250 v=0.750000 a=1.000000
D=0.50: T=1.414214 ta=0.707107 tc=0.000000 peak=0.707107
t=0.353553 x=0.062500 v=0.353553 a=1.000000
D=1.00: T=2.000000 ta=1.000000 tc=0.000000 peak=1.000000
t=0.500000 x=0.125000 v=0.500000 a=1.000000
D=-2.00: T=3.000000 ta=1.000000 tc=1.000000 peak=1.000000
t=0.750000 x=-0.281250 v=-0.750000 a=-1.000000
D=0.00: T=0.000000 ta=0.000000 tc=0.000000 peak=0.000000
t=0.000000 x=0.000000 v=0.000000 a=0.000000
Braking: x=1.875000 v=0.500000 a=-1.000000 stop=0.125000
These phases have closed-form solutions, so the example needs no integration step size. When a motion law lacks that convenience, numerical integration introduces a separate approximation error to check.
Try it yourself
Exercise 1. A carriage moves to D = −0.5 m with V = 1 m/s and A = 2 m/s². Does it cruise? Find total duration, then position and velocity at t = 0.25 s.
Show solution
The threshold is V²/A = 0.5 m, exactly equal to the travel length. The profile is triangular at the speed limit. Each ramp takes V/A = 0.5 s, cruise time is zero, and T = 1 s.
At 0.25 s it is accelerating in the negative direction. Position is −½ × 2 × 0.25² = −0.0625 m. Velocity is −2 × 0.25 = −0.5 m/s.
Exercise 2. A carriage moves toward its destination at 0.8 m/s. It has 0.1 m left and can brake at at most 2 m/s². Can it stop by the destination under this model? What speed magnitude would just allow it?
Show solution
Stopping distance is 0.8²/(2 × 2) = 0.16 m, which exceeds the remaining 0.1 m. Even immediate maximum braking cannot stop the carriage by the destination under these assumptions.
Set w²/(2A) = 0.1. The boundary speed is √(2 × 2 × 0.1) = √0.4 ≈ 0.632456 m/s. A real system also needs margin for delay and modeling error.
Sources and further study
- Lynch and Park, Modern Robotics, Sections 9.1–9.2, part 2: trapezoidal phases, acceleration discontinuities and S-curve timing.
- MathWorks, Design Trajectory with Velocity Limits Using Trapezoidal Velocity Profile: the velocity-area relationship and coordination issues across multiple dimensions.
- WPILib, Trapezoidal Motion Profiles: position and velocity reference states, consistent units, and their use with a controller.
- Lynch and Park, Modern Robotics, Section 9.4, part 1: the broader path-timing problem with robot dynamics and actuator limits.