TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

Trajectory Generation: Cubic and Quintic Polynomials, Trapezoidal, Minimum Jerk, Minimum Time Within Limits, Via-points

Status: Draft (2026-10-18), Measured. Numbers were directly calculated using Python 3.9.6 and numpy 2.0.2 on a laptop (Apple M1 Max, macOS 26.5). Raw data and code: working directory measure/robot-arm-basics/'s m08_traj.py, out/m08_traj.json. Joint velocity/acceleration limits and inertia are assumed values and not measured with actual motors (hardware not measured). Reference materials were accessed on 2026-10-18. Writing conventions: Measured data is the default; unmeasured items are marked as "Unmeasured", and unverified items are marked as "Unverified".

Table of Contents

1. Intuition: Like Driving

There are multiple ways to go from one traffic light to the next. Pushing the accelerator pedal to the floor and slamming on the brakes at the end arrives the fastest, but passengers lurch forward. Pressing it gently and releasing it gently is comfortable but slightly delayed. Robot joints are the same. Even when traveling the same distance in the same time, the peak velocity, torque required by the motor, and shock received by the arm vary depending on the shape of the velocity.

Table tennis robot trajectories have one additional special requirement. Instead of arriving at a stopped position, it must pass through at a specified time and a specified velocity because the racket speed determined in Part 7 must be produced at the moment of impact.

2. Figures: Shapes of Velocity

정지→정지 이동의 속도 모양(Δ와 T 로 정규화) 0 0.25 0.5 0.75 1 0 0.5 1 1.5 2 시간 t/T 속도 ÷ (Δ/T) 5차(최소 저크) 최고 1.875 3차 최고 1.5 사다리꼴 1.5 S-곡선 3차는 출발 순간 가속도가 0 이 아니다(6Δ/T²로 튐). 5차와 S-곡선은 0 에서 시작한다. 같은 시간이면 매끄러울수록 최고 속도가 높아진다.
Figure: Normalized velocity curves for cubic, quintic, trapezoidal, and S-curve trajectories

3. Calculations

3.1 Polynomial Time Scaling

When a single joint goes from q0 to q1 in time T, using τ = t/T, we write q(t) = q0 + (q1 − q0)·s(τ), where s is a function going from 0 to 1.

3차:  s = 3τ² − 2τ³                 끝점 조건: 위치·속도 (4개)
5차:  s = 10τ³ − 15τ⁴ + 6τ⁵          끝점 조건: 위치·속도·가속도 (6개)

Section 9.2.2.1 of Modern Robotics states that the peak velocity of a cubic is (3/2)·Δ/T (at the middle) and the peak acceleration is 6·Δ/T² (at both ends). Since the acceleration of a cubic suddenly changes from 0 to 6Δ/T² at the starting moment, the jerk (rate of change of acceleration) is infinite at that moment, and the same section explains that this can cause vibration. The quintic eliminates this problem by matching even the endpoint acceleration to 0. The quintic's peak velocity of 15/8·Δ/T and peak acceleration of 10/√3·Δ/T² were left as exercises rather than in the main text of the book, so they were calculated directly and verified numerically in Section 4.

3.2 Minimum Jerk and Minimum Acceleration

Quintic polynomials have another name. Among all smooth trajectories from rest to rest, it is the trajectory that minimizes the integral of squared jerk. Viewed through the calculus of variations, the function minimizing ∫(q⃛)² satisfies q⁽⁶⁾ = 0, making it a quintic polynomial, and 6 endpoint conditions uniquely determine the coefficients (our derivation). Flash and Hogan (1985) reported that human hand movement is well explained by a model that minimizes the integral of squared hand jerk (verified from the abstract, main text unverified).

By the same logic, minimizing the integral of squared accelerationyields q⁽⁴⁾ = 0, resulting in a cubic polynomial. The table tennis robot by Koç et al. (2018) optimized cubic polynomial trajectories for each joint based on this criterion. Since squared acceleration is proportional to squared torque, i.e., copper losses (heat) in the motor, this is an energy-based choice.

3.3 Trapezoidal, S-Curve, and Time-Optimal

When only velocity limits v_max and acceleration limits a_max are given, the fastest motion is "maximum acceleration → maintain peak velocity → maximum deceleration." Because the velocity curve is trapezoidal, it is called a trapezoidal profile, and if the distance is too short to reach peak velocity, it becomes a triangle (bang-bang).

Δ ≤ v_max²/a_max:   T_opt = 2·√(Δ / a_max)                 (삼각형)
그 밖:              T_opt = Δ / v_max + v_max / a_max        (사다리꼴)

The trapezoidal profile also has infinite jerk because acceleration changes stepwise. Limiting even acceleration changes results in a 7-segment S-curve where the acceleration phase is split into three parts again (Modern Robotics Section 9.2.2.3).

3.4 Hit Trajectory: Final Velocity is Not Zero

The joint trajectory of a table tennis robot consists of two parts.

  1. Swing: From the current state (rest) to (q_h, q̇_h, q̈ = 0) at hitting time T. Setting the acceleration to 0 at the moment of impact keeps the racket speed nearly constant during the brief contact duration.
  2. Stop (Follow-through): Returning to rest from that state.

Since a quintic polynomial can take any values for its 6 endpoint conditions, it can form both parts using the same function. A single 6x6 linear system yields the coefficients, and this calculation took 7.2 µs. This is also why Mülling et al. (2013) replaced the target movement of Dynamic Movement Primitives (DMPs) with a quintic polynomial to match endpoint velocity and acceleration (Section 3.2, Eq. 8).

def quintic_coeffs(q0, v0, a0, q1, v1, a1, T):
    A = [[1, 0, 0,    0,      0,       0      ],
         [0, 1, 0,    0,      0,       0      ],
         [0, 0, 2,    0,      0,       0      ],
         [1, T, T**2, T**3,   T**4,    T**5   ],
         [0, 1, 2*T,  3*T**2, 4*T**3,  5*T**4 ],
         [0, 0, 2,    6*T,    12*T**2, 20*T**3]]
    return np.linalg.solve(A, [q0, v0, a0, q1, v1, a1])     # q(t) = Σ c_k t^k

When ball prediction is updated, the current state (position, velocity, acceleration) is taken as a new starting point and re-solved for the remaining time. Because it connects continuously up to the starting point's acceleration, acceleration does not jump when corrections are made.

타격 궤적: 0.12초 만에 10 rad/s 로 지나고, 0.1초에 멈춘다 0 0.1 0.2 0.3 0 4 8 12 시간(초) 속도(rad/s) 0 0.4 0.8 1.2 각(rad) 타격 속도 각 구간 1: (0, 0, 0) → (0.6 rad, 10 rad/s, 0) 5차. 구간 2: 같은 상태 → 정지 5차. 타격 순간 가속도를 0 으로 두어 라켓 속도가 접촉 동안 거의 일정하다.
Figure: Joint angles and velocities of the hitting trajectory: passing at 10 rad/s at 0.12 seconds and stopping for 0.1 seconds

4. Measurements

4.1 Same Distance, Same Time, Different Shapes

Four trajectories moving Δ = 1 rad in T = 0.3 s were sampled at 100,001 points and numerically differentiated.

Trajectory Peak Velocity Peak Acceleration Starting Acceleration Peak Jerk (Internal) ∫Acceleration² dt
Cubic 5.00 rad/s 66.7 rad/s² 66.7 457 rad/s³ 444
Quintic (Min Jerk) 6.25 64.2 0.01 2,262 635
Trapezoidal (1/3 each) 5.00 50.0 50.0 (Step) 500
S-Curve (10% jerk phase) 5.00 71.4 0.03 2,385 612

Official values are cubic 5.0·66.7, quintic 6.25·64.15·2,222 (jerk), trapezoidal 5.0·50.0. Numerical differentiation results matched the formulas (quintic jerk is 2% larger due to finite difference error).

4.2 How Fast Can We Go Within Limits

Given joint limits (v_max, a_max), the minimum time of each trajectory was compared.

Limits Δ Time-Optimal Quintic Cubic Quintic ÷ Optimal
20 rad/s, 300 rad/s² 0.2 rad 0.052 s 0.062 s 0.063 s 1.20
20 rad/s, 300 rad/s² 1.0 rad 0.115 s 0.139 s 0.141 s 1.20
20 rad/s, 300 rad/s² 2.0 rad 0.167 s 0.196 s 0.200 s 1.18
10 rad/s, 100 rad/s² 1.0 rad 0.200 s 0.240 s 0.245 s 1.20
10 rad/s, 100 rad/s² 2.0 rad 0.300 s 0.375 s 0.346 s 1.25

Quintic polynomials are generally 20% slower than time-optimal. In short movements constrained by acceleration limits, this ratio remains constant at √(10/√3 ÷ 4) = 1.20 (our calculation). For fast balls where the time budget in Part 1 is tight, this 20% is precious. Therefore, time-optimal-like trajectories (trapezoidal, S-curve, or optimization with limits as constraints) are used, while smoothness is handled via S-curve jerk limits.

4.3 Minimum Time for Hit Trajectory

Trajectories starting from rest, passing Δ, and reaching q̇_h at that instant were minimized in time under a velocity limit of 20 rad/s and acceleration limits of 300 and 600 rad/s². For quintic, the shortest T was found via bisection, and time-optimal was found from the form "maximum acceleration → (if needed) maximum deceleration to q̇_h".

Δ q̇_h a_max Quintic T Time-Optimal T Extra angle/time to stop
0.3 rad 10 rad/s 300 0.054 s 0.046 s 0.17 rad, 33 ms
0.6 rad 10 rad/s 300 0.082 s 0.068 s 0.17 rad, 33 ms
0.6 rad 10 rad/s 600 0.062 s 0.051 s 0.08 rad, 17 ms
0.6 rad 15 rad/s 300 0.076 s 0.064 s 0.38 rad, 50 ms
1.0 rad 15 rad/s 300 0.102 s 0.085 s 0.38 rad, 50 ms

4.4 Via-Points: Stop or Continue

When a joint needs to pass through multiple via-points, two methods were compared: (a) quintic segments stopping at each via-point, and (b) cubic splines not stopping at via-points (zero velocity at both ends). For the splines, both equal segment timing and timing proportional to the square root of travel distance were used, and the minimum total time within limits (20 rad/s, 300 rad/s²) was found via bisection.

Via-Points (rad) Stopping Quintic Spline (Equal Intervals) Spline (Prop. to √Distance)
0 → 0.3 → 0.7 → 1.0 (One direction) 0.240 s 0.170 s 0.184 s
0 → 0.6 → 0.2 → 1.0 (Reversing) 0.319 s 0.357 s 0.325 s

For paths going in one direction, not stopping was 29% faster, but for paths changing direction, the speed has to drop to zero there anyway, making the quintic stop actually faster. The intuition that splines are always fast can be wrong, and how segment times are allocated is as important as the shape(Modern Robotics Section 9.3 covers via-point polynomials).

5. Limitations

6. Conclusion

Titi's Note: You should swing the racket toward where you are passing, not where you are stopping. And you must leave room to stop after hitting. Otherwise, your arm will hit the wall!

References

All materials were accessed on 2026-10-18.

Sign in to like

Comments

No comments yet.

Sign in to leave a comment