Skip to main content
Stage 5 · Chapter 25 · Theory

25. Trajectory Planning and Robot Arm Control

Chapter 25 of the Seeed Physical AI Beginner's Course — path versus trajectory, joint-space and Cartesian-space interpolation, linear, cubic and quintic polynomials, and the torque command built from feedforward (model and gravity) plus feedback error correction.

25.1 Learning Objectives​

Help the user understand how the arm generates smooth, safe continuous motion from a target pose.

After this chapter you should be able to:

  1. Separate a motion into a path (shape) and a trajectory (timing), and say which one a task constrains.
  2. Choose between joint-space and Cartesian-space interpolation.
  3. Explain the difference between linear, cubic and quintic interpolation, and why the start/stop behavior matters.
  4. Explain feedforward, feedback and gravity compensation, and how the torque command is composed.
Path versus trajectory (1/2)
Path and trajectory in a robot arm (2/2)

25.2 Path vs. Trajectory​

Imagine walking from home to the office.

Path = the route you take (shape)

Turn left out the door, take the main road, cross the bridge, turn right, arrive at the office

No matter how fast or slow you walk, this route stays the same.

Trajectory = the pace you walk at (time + speed)

Walk out the door in 10 seconds, pause on the bridge for 1 minute, wait at the red light downstairs for 30 seconds

Same road, fast or slow walking differs.

Core difference

DimensionPathTrajectory
DescriptionWhereWhere + when
DomainSpaceSpace + time
ConcernsShapeTime, velocity, acceleration
Example"Go straight from A to B""Go from A to B at constant speed in 5 seconds"

Mapping in the robot arm

TaskPathTrajectory
WeldingWeld seam shapeMovement speed along the seam
GraspingFrom A to the cup rimWhen to arrive, how long to hold
PaintingPaint areaSprayer movement speed

Planning order:

  1. First define the path (shape)

  2. Then define the trajectory (when to be where)

A concrete example

The arm moves a cup from point A to point B.

Path (shape only):

Lift up -> extend forward -> lower

(a spatial curve)

Trajectory (with time):

Lift 1 s -> pause 0.5 s -> extend 2 s -> lower 1 s

(joint angles at each moment)

The path can be right while the trajectory is wrong (e.g. too aggressive, cup flies off); the trajectory being right requires the path to be right first (a wrong path makes an accurate trajectory useless).

Why discuss them separately

StageConcerns
Path planningAvoid obstacles, find a feasible shape
Trajectory planningMake motion smooth, without shaking or over-speed

Path is a geometric problem; trajectory is a timing problem.

The arm's trajectory must be "smooth"

Not just "from A to B", but also:

  • Continuous velocity (no sudden jumps to/from 0)
  • Continuous acceleration (no sudden jerk)
  • Within motor speed limits
  • Within torque limits

All of these belong to trajectory planning.

25.3 Joint-Space and Cartesian-Space Trajectories​

Trajectory from boundary conditions
DimensionJoint-space trajectoryCartesian-space trajectory
Interpolated objectJoint anglesEnd-effector pose
Interpolation functionPolynomialLine / arc / geodesic
Velocity propertyConstant joint velocityConstant end-effector velocity

So "joint vs. Cartesian" is discussed at both levels, but what is most often asked is at the path level — because that is the key to the arm "doing different things."

Why the path gets more attention

TaskWhich path to chooseReason
WeldingCartesian (straight line)The weld seam is a straight line
PaintingCartesian (specific curve)The paint surface must be covered
PalletizingEither joint spaceThe end path doesn't matter
Free transportJoint spaceNo need to care about the end path
Place after pickingJoint spaceNo straight-line requirement
warning

A Cartesian-space trajectory is the natural way to describe a task, but it is the expensive way to execute it: every sampled pose needs an IK solution. Plan in Cartesian space, then check that the resulting joint trajectory respects the joint limits and stays away from singularities — or generate the path in Cartesian space and the timing in joint space.

25.4 Linear Interpolation​

Why linear interpolation jolts

Joint-space trajectory:

θ(t)=θstart+(θend−θstart) t\theta(t) = \theta_{start} + (\theta_{end} - \theta_{start})\,t

The joint smoothly goes from 0 deg to 90 deg, taking a value every 10% along the way.

Position-space trajectory:

p(t)=pstart+(pend−pstart) t\mathbf{p}(t) = \mathbf{p}_{start} + (\mathbf{p}_{end} - \mathbf{p}_{start})\,t

The end moves in a straight line from (0,0,0)(0, 0, 0) to (1,0,0)(1, 0, 0); an intermediate position is pstart+s (pend−pstart)\mathbf{p}_{start} + s\,(\mathbf{p}_{end} - \mathbf{p}_{start}), where the ratio ss goes from 0 to 1.

Pros & cons

The problem is the velocity profile: the joint moves at a constant, non-zero speed and then stops instantly.

θ˙(t)=θend−θstartT≠0,θ¨(t)=0\dot{\theta}(t) = \frac{\theta_{end} - \theta_{start}}{T} \ne 0, \qquad \ddot{\theta}(t) = 0

Pros:

  • Simple and easy to compute
  • Done in one line of code
  • High real-time performance

Cons:

  • Velocity jumps at the start and end (it is not zero there)
  • The arm "jolts" at start/stop
  • Not suitable for high-precision tasks

The start/stop "jolt" is the core problem — so finer trajectories use cubic/quintic polynomials.

25.5 Polynomial Interpolation​

Why polynomials are needed

Linear, cubic and quintic polynomials

Core differences

DimensionLinearCubicQuintic
Start/stop velocityJump00
Start/stop accelerationJumpJump0
SmoothnessPoorMediumGood
Compute loadMinimumMediumMedium
Best forRough motionGeneral purposeHigh precision

Applications in robot arms

ScenarioWhich to use
Rough transport, palletizingCubic
Welding, assemblyQuintic
Collaborative robotsQuintic (must be stable around humans)
High-speed motionCubic (sufficient)
Research / demoQuintic (smoothest)
Linear:θ(t)=a0+a1tCubic:θ(t)=a0+a1t+a2t2+a3t3Quintic:θ(t)=a0+a1t+a2t2+a3t3+a4t4+a5t5\begin{aligned} \text{Linear:}\quad \theta(t) &= a_0 + a_1 t \\ \text{Cubic:}\quad \theta(t) &= a_0 + a_1 t + a_2 t^2 + a_3 t^3 \\ \text{Quintic:}\quad \theta(t) &= a_0 + a_1 t + a_2 t^2 + a_3 t^3 + a_4 t^4 + a_5 t^5 \end{aligned}

Quintic with rest-to-rest boundary conditions — the arm starts at rest and stops at rest:

θ(0)=0,θ˙(0)=0,θ¨(0)=0θ(T)=90∘,θ˙(T)=0,θ¨(T)=0\begin{aligned} \theta(0) &= 0, & \dot{\theta}(0) &= 0, & \ddot{\theta}(0) &= 0 \\ \theta(T) &= 90^\circ, & \dot{\theta}(T) &= 0, & \ddot{\theta}(T) &= 0 \end{aligned}

Six conditions, six unknowns a0,a1,…,a5a_0, a_1, \ldots, a_5 — a unique solution.

25.6 Feedforward, Feedback, and Gravity Compensation​

Feedforward versus feedback

The torque sent to the motor is the sum of two things:

τcmd=τfeedforward⏟computed in advance, incl. gravity compensation+τfeedback⏟corrected from the error, fixes what goes wrong\tau_{cmd} = \underbrace{\tau_{feedforward}}_{\text{computed in advance, incl. gravity compensation}} + \underbrace{\tau_{feedback}}_{\text{corrected from the error, fixes what goes wrong}}

Feedforward: send in advance based on the model

Given the trajectory and the arm's parameters, how much torque is needed at each moment can be computed:

Model containsPurpose
Inertia termOvercome inertia when accelerating
Coriolis termCounter coupling when turning
Gravity termPresent even when the arm is still; directly cancels gravity

The gravity term is especially important — the arm must send it even while standing still, otherwise gravity pulls it down.

Analogy: knowing there's a 5 km uphill today, build up the effort in advance.

Feedback: fix when something is wrong

No matter how accurate the model, there are errors and external disturbances -> the actual position drifts.

Feedback is real-time comparison and real-time correction:

  • How far off -> add that much (position feedback)
  • How fast it drifts -> damp that much (velocity feedback)

Analogy: knowing there's an uphill today, but there are potholes on the road — steer around them when you see them.

How the two work together

SourceRoleShare (typical)
FeedforwardMost of the torque80~95%
FeedbackCompensate small errors5~20%

Feedforward handles the bulk, feedback handles the small remainder — together they are fast and accurate.

Comparison

DimensionFeedforwardFeedback
TimingCompute in advanceCorrect in real time
Depends onModel accuracySensor readings
ResponseImmediateLags one frame
Disturbance rejectionPoorStrong
IncludesIncludes gravity compensationDoes not

What the actual controller looks like

τcmd=τfeedforward+τfeedback=[M(q) q¨+C(q,q˙) q˙+G(q)]⏟feedforward (incl. gravity)+[Kp e+Kd e˙]⏟feedback\begin{aligned} \tau_{cmd} &= \tau_{feedforward} + \tau_{feedback} \\ &= \underbrace{\big[ M(q)\,\ddot{q} + C(q, \dot{q})\,\dot{q} + G(q) \big]}_{\text{feedforward (incl. gravity)}} + \underbrace{\big[ K_p\,e + K_d\,\dot{e} \big]}_{\text{feedback}} \end{aligned}

Gravity is inside feedforward — no need to compute it separately.

In one sentence

Feedforward sends torque in advance based on the model (including gravity); feedback compensates in real time based on error; gravity need not be mentioned separately — it is the sub-term in feedforward that must be computed even when the arm is still.

  • Path = geometry, trajectory = timing; plan the path first, then the timing.
  • Joint-space interpolation is cheap and singularity-free; Cartesian-space interpolation is what the task usually asks for.
  • Linear interpolation jolts; cubic removes the velocity jump and quintic also removes the acceleration jump.
  • The torque command is feedforward (model + gravity) plus feedback (error correction); gravity lives inside feedforward.
  • Next chapter: run all of this on the real reBot Arm model with Pinocchio and MeshCat.
Loading Comments...