|
| 1 | +# Polynomial Point-to-Point Profile |
| 2 | + |
| 3 | +## Overview & Motivation |
| 4 | + |
| 5 | +A polynomial profile is a closed-form time law that drives one axis from a start state to a goal state over a fixed duration $T$. A **cubic** matches endpoint position and velocity; a **quintic** additionally matches endpoint acceleration, so the motion has no acceleration step at either end. |
| 6 | + |
| 7 | +Point-to-point moves are the bread and butter of servo motion: robot joints, CNC and pick-and-place axes, motor position loops. The coefficients come from a handful of algebraic expressions, solved once. Each servo tick is then a fixed number of multiply-adds, with no iteration, no lookup table and a deterministic cycle count. |
| 8 | + |
| 9 | +## Mathematical Theory |
| 10 | + |
| 11 | +### Boundary Conditions |
| 12 | + |
| 13 | +Let $t \in [0, T]$, $\Delta q = q_f - q_0$, and let $\alpha_0, \alpha_f$ be the start and end accelerations. A polynomial of degree $n$ has $n+1$ coefficients, so a cubic satisfies four conditions and a quintic six: |
| 14 | + |
| 15 | +$$q(0) = q_0,\quad q(T) = q_f,\quad \dot{q}(0) = v_0,\quad \dot{q}(T) = v_f \qquad \text{(quintic also: } \ddot{q}(0) = \alpha_0,\ \ddot{q}(T) = \alpha_f\text{)}$$ |
| 16 | + |
| 17 | +The conditions are linear in the coefficients $a_k$ of $q(t) = \sum_k a_k t^k$ and the time basis is fixed, so the solution is a plug-in formula rather than a runtime matrix solve. |
| 18 | + |
| 19 | +### Cubic |
| 20 | + |
| 21 | +The start conditions give $a_0 = q_0$ and $a_1 = v_0$. The end conditions leave a $2\times 2$ system with the closed-form solution |
| 22 | + |
| 23 | +$$a_2 = \frac{3\,\Delta q - (2 v_0 + v_f)\,T}{T^2}, \qquad a_3 = \frac{-2\,\Delta q + (v_0 + v_f)\,T}{T^3}$$ |
| 24 | + |
| 25 | +The acceleration is linear in $t$ and the jerk is the constant $6 a_3$. |
| 26 | + |
| 27 | +### Quintic |
| 28 | + |
| 29 | +The start conditions give $a_0 = q_0$, $a_1 = v_0$, $a_2 = \alpha_0 / 2$. The end conditions give |
| 30 | + |
| 31 | +$$a_3 = \frac{20\,\Delta q - (8 v_f + 12 v_0)\,T - (3\alpha_0 - \alpha_f)\,T^2}{2\,T^3}$$ |
| 32 | + |
| 33 | +$$a_4 = \frac{-30\,\Delta q + (14 v_f + 16 v_0)\,T + (3\alpha_0 - 2\alpha_f)\,T^2}{2\,T^4}$$ |
| 34 | + |
| 35 | +$$a_5 = \frac{12\,\Delta q - 6 (v_f + v_0)\,T - (\alpha_0 - \alpha_f)\,T^2}{2\,T^5}$$ |
| 36 | + |
| 37 | +The acceleration is a cubic matching $\alpha_0$ and $\alpha_f$, hence continuous; the jerk is a quadratic. |
| 38 | + |
| 39 | +### Sampling |
| 40 | + |
| 41 | +Position, velocity, acceleration and jerk are four Horner evaluations of the polynomial and its three derivatives: |
| 42 | + |
| 43 | +$$q = a_0 + t\big(a_1 + t(a_2 + t(a_3 + t(a_4 + t\,a_5)))\big), \qquad \dddot{q} = 6 a_3 + t\,(24 a_4 + 60 a_5\, t)$$ |
| 44 | + |
| 45 | +The cubic is the same evaluation with $a_4 = a_5 = 0$. The time is first clamped to $[0, T]$. |
| 46 | + |
| 47 | +### Rest-to-Rest Peaks |
| 48 | + |
| 49 | +With zero end velocities (and accelerations, for the quintic) the cubic peaks at $1.5\,\Delta q / T$ in velocity and $6\,\Delta q / T^2$ in acceleration; the quintic at $1.875\,\Delta q / T$ and $\tfrac{10}{\sqrt{3}}\,\Delta q / T^2 \approx 5.77\,\Delta q / T^2$. |
| 50 | + |
| 51 | +## Complexity Analysis |
| 52 | + |
| 53 | +| Operation | Time | Space | Notes | |
| 54 | +|-----------|------|-------|-------| |
| 55 | +| Coefficient solve | $O(1)$ | $O(1)$ | Closed-form expressions, once at construction or reset | |
| 56 | +| Sample | $O(\text{degree})$ | $O(1)$ | Four Horner evaluations, at most 14 multiply-adds; no state change, so deterministic | |
| 57 | +| Stored state | n/a | $O(1)$ | Six coefficients, the duration and the degree; stack only, no heap | |
| 58 | + |
| 59 | +## Step-by-Step Walkthrough |
| 60 | + |
| 61 | +Rest-to-rest cubic with $q_0 = 0$, $q_f = 1$, $T = 2$, $v_0 = v_f = 0$, so $\Delta q = 1$ and $a_0 = a_1 = 0$. |
| 62 | + |
| 63 | +| Step | Computation | Result | |
| 64 | +|------|-------------|--------| |
| 65 | +| $a_2$ | $(3\cdot 1 - 0)/2^2$ | $0.75$ | |
| 66 | +| $a_3$ | $(-2\cdot 1 + 0)/2^3$ | $-0.25$ | |
| 67 | +| Position | $0.75\,t^2 - 0.25\,t^3 = 3(t/2)^2 - 2(t/2)^3$ | $q(1) = 0.5$, $q(2) = 1$ | |
| 68 | +| Velocity | $1.5\,t - 0.75\,t^2$ | $v(1) = 0.75 = 1.5\,\Delta q / T$ (the peak) | |
| 69 | +| Acceleration | $1.5 - 1.5\,t$ | $+1.5$ at $t=0$, $-1.5$ at $t=2$ | |
| 70 | +| Jerk | $6 a_3$ | $-1.5$, constant | |
| 71 | + |
| 72 | +The position is the smoothstep of $t/2$, symmetric about the midpoint, where the velocity peaks. The acceleration jumps from $0$ at rest to $1.5$ at the first instant and from $-1.5$ back to $0$ at the end. |
| 73 | + |
| 74 | +## Pitfalls & Edge Cases |
| 75 | + |
| 76 | +- **Duration must be positive.** The coefficients contain $1/T^k$ terms; a zero or negative duration is rejected at construction and reset. |
| 77 | +- **Short durations in single precision.** Higher-order coefficients grow like $1/T^5$ for the quintic, and terms of opposite sign cancel near the end of the move, losing digits. |
| 78 | +- **Clamped time holds the endpoint state.** Outside $[0, T]$ the sample is the state at $0$ or $T$, so it reports the end velocity and acceleration, not zero, when they are nonzero. |
| 79 | +- **Acceleration steps in the cubic.** Acceleration is not matched, so at rest endpoints it jumps from or to zero, which excites flexible loads. The quintic's jerk is finite but generally nonzero at the ends. |
| 80 | +- **No limit enforcement.** Peaks follow from $\Delta q$, $T$ and the boundary values; inconsistent boundary velocities can overshoot $q_f$ before returning. |
| 81 | + |
| 82 | +## Variants & Generalizations |
| 83 | + |
| 84 | +| Variant | Key difference | |
| 85 | +|---------|----------------| |
| 86 | +| **Cubic (this)** | Position and velocity matched; constant jerk; acceleration discontinuous at the ends | |
| 87 | +| **Quintic (this)** | Adds acceleration matching; continuous acceleration at about $25\%$ higher peak velocity for rest-to-rest | |
| 88 | +| **Path-parameter time law** | A 0 to 1 instance maps time to a normalized path coordinate; with $v_0 = v_f = 1$, $T = 1$ the cubic collapses to $s = t$ | |
| 89 | + |
| 90 | +## Applications |
| 91 | + |
| 92 | +- **Joint-space moves** — robot joints and servo axes between taught points; multi-axis moves use one instance per axis with a common $T$ so all axes arrive together. |
| 93 | +- **Pick-and-place and CNC positioning** — fixed-time axis moves where smoothness matters more than minimum time. |
| 94 | +- **Path timing** — the scalar time law along a geometric path such as an orientation interpolation. |
| 95 | + |
| 96 | +## Connections to Other Algorithms |
| 97 | + |
| 98 | +| Algorithm | Relationship | |
| 99 | +|-----------|--------------| |
| 100 | +| Trapezoidal velocity profile | Respects velocity and acceleration limits with a free duration; polynomials fix the duration and let the peaks follow | |
| 101 | +| S-curve profile | Bounds jerk explicitly under limits; the quintic only smooths the endpoints | |
| 102 | +| Cubic spline interpolation | Handles many via points with continuous acceleration; for two knots it reduces to this cubic | |
| 103 | + |
| 104 | +## References & Further Reading |
| 105 | + |
| 106 | +- Craig, J. J., "Introduction to Robotics: Mechanics and Control," 3rd ed., Pearson, 2005, Chapter 7 (trajectory generation). |
| 107 | +- Biagiotti, L. and Melchiorri, C., "Trajectory Planning for Automatic Machines and Robots," Springer, 2008, §2.1. |
0 commit comments