Trajectory Generation: Polynomials, Profiles & Cartesian Paths
Turning goals into smooth, feasible motion. Learn path vs trajectory, point-to-point joint moves, cubic and quintic polynomials with boundary conditions, trapezoidal (LSPB) and S-curve (jerk-limited) velocity profiles, synchronising multiple joints, multi-point paths with via points and blending (splines), Cartesian straight-line and circular moves (with orientation interpolation via slerp), time-optimal scaling under velocity/acceleration/torque limits, and robot move instructions (MoveJ, MoveL, MoveC) — with Python for a quintic trajectory and a trapezoidal move time.
A path says where to go; a trajectory also says when. Smooth trajectories with bounded velocity, acceleration and jerk reduce vibration, wear and cycle time, and keep motors within limits.
Every robot program's MoveJ/MoveL command is executed by a trajectory generator — understanding it helps optimise cycle times and avoid jerky motion.
An analogy
A good trajectory is like a smooth car journey: gently accelerate, cruise, then brake smoothly to stop exactly at the destination — rather than flooring the pedal and slamming the brakes.
Joint-space vs Cartesian-space
Joint interpolation (MoveJ/PTP): each joint moves smoothly from start to goal, synchronised to finish together — fastest and never hits singularities, but the tool path is curved. Cartesian interpolation (MoveL/LIN, MoveC/CIRC): the tool follows a straight line or arc — needed for welding, dispensing and inserting, but requires IK at every step and can pass near singularities or joint limits.
Profile types
Choosing a time law:
- Cubic — continuous velocity, acceleration jumps at ends
- Quintic — continuous acceleration, smooth; longer for the same limits
- Trapezoidal (LSPB) — constant acceleration, cruise, deceleration; time-efficient
- S-curve (7-segment) — jerk-limited; reduces vibration, standard in modern controllers
- Splines (cubic, B-spline) through via points for multi-segment smooth paths
Blending and synchronisation
Multi-point programs blend corners (zone/approximation data such as ABB z10, Fanuc CNT) so the robot doesn't stop at each via point — big cycle-time gains. Joint moves are synchronised by stretching faster joints to the slowest joint's time. Orientation in Cartesian moves is interpolated with quaternion slerp for constant angular velocity.
Time-optimal and dynamic feasibility
Time-optimal path parameterisation (TOPP, TOPP-RA) finds the fastest speed profile s(t) along a given path subject to joint velocity, acceleration and torque limits using dynamics. Optimisation-based trajectory generation (CHOMP, TrajOpt, MPC) handles obstacles and smoothness together. Online trajectory generators (Ruckig) recompute jerk-limited motions every control cycle for reactive behaviour.
Formulas
- Cubic (rest to rest):
q = q₀ + 3Δq(t/T)² − 2Δq(t/T)³ - Quintic (rest to rest, zero accel):
q = q₀ + Δq[10(t/T)³ − 15(t/T)⁴ + 6(t/T)⁵] - Quintic peaks:
q̇_max = 1.875Δq/T; q̈_max = 5.774Δq/T² - Trapezoidal time:
T = D/v_max + v_max/a_max (if D > v_max²/a_max) - Triangular time:
T = 2√(D/a_max) (if D ≤ v_max²/a_max) - Cartesian line:
p(s) = p₀ + s(p₁ − p₀); R(s) = slerp(R₀, R₁, s)
Worked example: Cubic midpoint velocity
Given: Δq = 60°, T = 2 s
Find: Peak velocity.
- 1.5Δq/T
Answer: 45°/s
Worked example: Trapezoidal time
Given: D 120°, v_max 100°/s, a_max 200°/s²
Find: T.
- 120/100 + 100/200
Answer: 1.7 s
Worked example: Triangular case
Given: D 20°, v_max 100°/s, a_max 200°/s²
Find: T.
- D < v²/a = 50 → 2√(20/200)
Answer: 0.63 s (never reaches v_max)
Quintic joint trajectory and trapezoidal move time
import numpy as np
# Quintic polynomial joint trajectory (zero start/end velocity and acceleration) and trapezoidal profile
q0, qf, T = 0.0, np.radians(90), 2.0
a3, a4, a5 = 10 * (qf - q0) / T**3, -15 * (qf - q0) / T**4, 6 * (qf - q0) / T**5
for t in (0.0, 0.5, 1.0, 1.5, 2.0):
q = q0 + a3*t**3 + a4*t**4 + a5*t**5
qd = 3*a3*t**2 + 4*a4*t**3 + 5*a5*t**4
print(f"t = {t:.1f} s: q = {np.degrees(q):6.2f} deg, qd = {np.degrees(qd):6.2f} deg/s")
print(f"peak velocity {np.degrees(1.875*(qf-q0)/T):.1f} deg/s, peak acceleration {np.degrees(5.7735*(qf-q0)/T**2):.1f} deg/s2")
# Trapezoidal: vmax 90 deg/s, amax 180 deg/s2, move 90 deg
D, vmax, amax = 90.0, 90.0, 180.0
ta = vmax / amax
T_trap = D / vmax + ta if D > vmax**2 / amax else 2 * np.sqrt(D / amax)
print(f"trapezoidal move time {T_trap:.2f} s (accel phase {ta:.2f} s)")
# t = 0.0 s: q = 0.00 deg, qd = 0.00 deg/s
# t = 0.5 s: q = 9.32 deg, qd = 47.46 deg/s
# t = 1.0 s: q = 45.00 deg, qd = 84.38 deg/s
# t = 1.5 s: q = 80.68 deg, qd = 47.46 deg/s
# t = 2.0 s: q = 90.00 deg, qd = 0.00 deg/s
# peak velocity 84.4 deg/s, peak acceleration 129.9 deg/s2
# trapezoidal move time 1.50 s (accel phase 0.50 s)The quintic starts and stops with zero velocity and acceleration, giving smooth motion with no jerk spikes at the ends; its symmetric velocity peaks at mid-move. A trapezoidal profile using the same limits (90°/s, 180°/s²) finishes in 1.5 s instead of 2 s by spending more time at maximum velocity — at the cost of acceleration steps (infinite jerk), which S-curve profiles smooth out.
Common mistakes
- Wrong: Linear moves through singular regions. — Right: Use joint moves or re-plan the path.
- Wrong: Fine stops at every via point. — Right: Use blending zones where accuracy allows.
- Wrong: Ignoring jerk. — Right: S-curves reduce vibration and settling time.
Applications
- Welding and dispensing: Constant-speed Cartesian paths.
- Palletising: Blended moves for short cycle times.
- CNC & 3D printers: Jerk-limited motion planning.
- Camera robots: Smooth splines for cinematography.
Key takeaways
- Path + timing = trajectory.
- Cubic/quintic for smoothness; trapezoidal/S-curve for speed.
- MoveJ fast; MoveL/MoveC for tool paths.
- Blend corners and respect dynamic limits.
Going further
- TOPP-RA: Time-optimal path parameterisation.
- Ruckig: Online jerk-limited trajectories.
- Trajectory optimisation: CHOMP, TrajOpt, MPC.