ข้ามไปยังเนื้อหา

บทเรียนที่ 17 · Actuators and Control

Trajectory Generation

Generate smooth robot motion in time: cubic and quintic polynomials, trapezoidal velocity profiles, multi-point paths and synchronized joints, with Python plots.

A controller such as PID tracks a setpoint, but what should the setpoint be over time? If you command a joint to jump from 0 to 90 degrees instantly, the error is huge, the motor saturates, the arm jerks and the gears take a hammer blow. A trajectory is a plan of position (and velocity, acceleration) as a function of time that gets from A to B smoothly, within the limits of the hardware.

A path is purely geometric (the points through which to pass); a trajectory adds timing. This lesson covers the standard single-joint profiles and how to use them for several joints at once.

What makes a trajectory good

  • Continuity: position and velocity should be continuous; acceleration continuous too if you want to avoid jerk (sudden force changes that excite vibrations).
  • Respect limits: maximum velocity, acceleration and sometimes jerk.
  • Boundary conditions: start and end positions and velocities (usually zero at rest).
  • Simplicity: cheap to compute on a microcontroller.

Cubic polynomial

A cubic q(t) = a0 + a1 t + a2 t² + a3 t³ has four coefficients, enough to set position and velocity at both ends. For a rest-to-rest move from q0 to q1 in time T:

Text
a0 = q0,  a1 = 0
a2 =  3 (q1 - q0) / T²
a3 = -2 (q1 - q0) / T³

The velocity is zero at both ends but acceleration jumps there (a step in acceleration, so jerk is infinite for an instant). That is acceptable for many robots.

Quintic polynomial

A fifth-order polynomial has six coefficients, so you can also set the acceleration at each end, usually zero. The rest-to-rest quintic uses the "smoothstep" shape:

q(t) = q0 + (q1 - q0) (10 s³ - 15 s⁴ + 6 s⁵), with s = t / T.

Velocity and acceleration both start and end at zero, so the motion is gentler.

Python Cubic versus quintic rest-to-rest moves

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The cubic's acceleration is at its largest right at the start, a sudden jump (about 134 deg/s²); the quintic starts and ends at zero acceleration and has a slightly lower acceleration peak, but needs a higher peak velocity (84 versus 67 deg/s) to cover the same distance in the same time. Pick according to what the hardware dislikes more.

Trapezoidal velocity profile

Industrial controllers and motor drivers love the trapezoidal profile. Accelerate at a constant rate until reaching the maximum velocity vmax, cruise, then decelerate at the same rate. Velocity looks like a trapezoid. It is optimal in time when the limits are on velocity and acceleration, and trivial to compute. If the distance is too short to reach vmax, the profile becomes a triangle.

Given distance D = |q1 - q0|, maximum acceleration a and maximum velocity v:

  • acceleration time ta = v / a; the distance used for speeding up and braking is v² / a.
  • If D > v² / a: trapezoid with cruise time tc = (D - v²/a) / v; total T = 2 ta + tc.
  • Else: triangle with peak speed sqrt(a D), T = 2 sqrt(D / a).
Python Trapezoidal profile generator

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Pure trapezoids have a step change in acceleration. S-curve profiles smooth it by limiting jerk too, trading a longer duration for less vibration; they are standard in CNC machines and robot arms carrying delicate loads.

Via points and splines

Often the arm must pass through several via points: pick up, lift, move across, place. Running a separate rest-to-rest move per leg makes the arm stop at each point. Instead, fit a spline: piecewise cubics that join with continuous velocity and acceleration. A cubic spline through points at given times can be computed with a small linear system (SciPy's CubicSpline does it), or with the simple rule "choose via-point velocities as the average of neighboring slopes".

Python A smooth path through via points

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The arm flows through each via point without stopping, and velocity is continuous.

Several joints and Cartesian paths

For a multi-joint arm, the simplest coordinated scheme is synchronization: compute the time each joint needs (from its distance and limits), take the longest, and rescale all joints to that duration. They all start and finish together. Joint-space motion is easy and avoids singularities but makes the tip follow a curved path. If the tool must follow a straight line (welding, drawing), interpolate in task space, a line in (x, y, z) plus an orientation blend, and convert each point using inverse kinematics or resolved rates (Jacobian).

Python Joint-space versus straight-line tip motion

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is the difference between a path and a trajectory?

    The path says where to go; the trajectory says when to be there.
  2. 2. Which boundary conditions can a quintic polynomial satisfy that a cubic cannot?

    A quintic has six coefficients: position, velocity and acceleration at both ends.
  3. 3. When does a trapezoidal profile become a triangle?

    If D <= vmax^2 / amax the robot must start braking before it reaches vmax.
  4. 4. Why interpolate in task space instead of joint space?

    Straight joint-angle ramps produce curved tip paths. Task-space interpolation needs IK but yields straight tip motion.

Summary

  • A trajectory is a time-parameterized path with limits on velocity, acceleration and jerk.
  • Cubic polynomials set position and velocity at the ends; quintics also set acceleration; trapezoids use constant acceleration and a cruise speed.
  • Spline interpolation passes smoothly through via points without stopping.
  • Synchronize joints by stretching to the slowest one; use task-space interpolation for straight tool paths.

Next: Mobile Robot Control

ติดตามความคืบหน้าของคุณ

สร้างบัญชีฟรีเพื่อติ๊กบทเรียนที่เรียนแล้วและเรียนต่อจากจุดเดิมได้บนทุกอุปกรณ์