# Module 3.5: Trajectory Smoothing and Time Parameterization

- Course: [Course 3: Motion Planning & Navigation](https://roboticsconcepts.dev/courses/motion-planning-navigation.md)
- HTML Page: https://roboticsconcepts.dev/courses/motion-planning-navigation/trajectory-smoothing-time-parameterization/
- Key Concepts: Cubic & quintic splines, Trapezoidal & S-curve velocity profiles, Velocity, acceleration & jerk bounds

If you send a raw A* or RRT waypoint list straight to a robot's motors, the machine will shudder, slam into corners, and sound like it's shaking its own bolts loose. A geometric path only tells you where to go — not when to be there or how smoothly to accelerate.

## From geometric breadcrumbs to time-stamped motion

Think about driving to a grocery store. Knowing the turn-by-turn street route is a path. Deciding to ease onto the gas, cruise at 35 mph, and feather the brake before the red light is a trajectory — a path parameterized by time, q(t).

Real actuators cannot teleport from zero speed to full speed in zero seconds (infinite acceleration), and gearboxes hate instantaneous jumps in acceleration (infinite jerk). Every motion controller needs smooth time profiles that stay inside hardware limits.

## Trapezoidal ramps vs. minimum-jerk splines

Two classic velocity profiles show up on nearly every conveyor, CNC machine, and robot arm:

- Trapezoidal velocity profile: accelerate at full +a_max up to v_max, cruise flat, then brake at −a_max. It finishes the move as fast as possible for given (v_max, a_max), or collapses into a triangle on short moves — at the cost of sharp corners in velocity (infinite jerk spikes).
- Minimum-jerk (quintic) polynomial: fits a 5th-degree curve q(t) with zero velocity and zero acceleration at both start and finish. Velocity becomes a smooth bell curve, acceleration rises and falls gently, and jerk stays continuous and bounded.

## Interactive Sandbox: Trajectory Spline & Velocity Profile Tuner

Adjust travel distance Δq, v_max, and a_max below, then flip between Trapezoidal and Minimum-Jerk (Quintic). Compare the sharp acceleration steps and jerk spikes on the trapezoidal profile against the smooth S-shaped curves of the quintic spline.

## Trading milliseconds for mechanical kindness

Look closely at the total duration T when you toggle modes under the same v_max and a_max bounds. The trapezoidal profile always gets there slightly faster because it spends time pinned right at the hardware ceiling.

The quintic minimum-jerk profile takes a bit longer, yet it dramatically cuts vibration, prevents drinks from sloshing on a tray, and reduces wear on belts and harmonic drives. When chaining multiple waypoints together, cubic or quintic splines keep velocity and acceleration continuous across every intermediate corner so the arm glides instead of stopping and starting at every dot.

## Quintic minimum-jerk time scaling

```text
q(τ) = q₀ + Δq · (10τ³ − 15τ⁴ + 6τ⁵),   τ = t / T ∈ [0, 1]
```

This unique 5th-degree polynomial satisfies zero velocity and zero acceleration at τ = 0 and τ = 1 while minimizing the integral of squared jerk ∫ j(t)² dt over the move.

## Check Your Intuition

**Question:** Suppose you command a short 0.3 m move with a high v_max = 3.0 m/s and moderate a_max = 1.5 m/s². What happens to a trapezoidal velocity profile?

- [ ] It refuses to move because v_max wasn't reached
- [✓] It never reaches v_max and collapses into a triangular profile, accelerating halfway and immediately braking
- [ ] It automatically switches to a constant-speed rectangle

**Explanation:** When Δq < v_max² / a_max, there isn't enough distance to accelerate all the way to v_max and brake back down. The cruise phase vanishes and the trapezoid becomes a triangle.

## Where You'll See This in Modern Robotics

Industrial arms and diffusion/VLA action-chunking policies alike rely on smooth trajectory execution: libraries like Ruckig compute jerk-limited S-curve profiles online in microseconds, while robot controllers interpolate policy waypoints at 100–1000 Hz.

## Companion Python Notebook: 05 · Trajectory Smoothing & Time Parameterization

Generate trapezoidal and quintic minimum-jerk trajectories and inspect position, velocity, acceleration, and jerk limits.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-3/05_trajectory_smoothing_time_parameterization.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-3/05_trajectory_smoothing_time_parameterization.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-3/05_trajectory_smoothing_time_parameterization.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-3/05_trajectory_smoothing_time_parameterization.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-3/05_trajectory_smoothing_time_parameterization.py`
