Skip to the content
FixTheRobot Explore Robotics / Manipulator Basics / Theory / 11

Manipulator Basics · Theory · Module 11 of 14

11 — Manipulator Control

A trajectory is only a wish until a controller makes the joints follow it. Compare joint PID, PID with gravity compensation and computed-torque control on a simulated 2R arm with real dynamics, read the step-response metrics, and see how impedance and admittance control handle contact.

  • Advanced
  • About 8 minutes to read
  • 1 linked lab

Every robot joint has a motor, a sensor and a control loop. How much the controller knows about the arm's dynamics decides how accurately it tracks, how it handles payloads and disturbances, and how safely it touches the world.

Learning objectives

After this module you should be able to:

  • Describe the position, velocity and torque command interfaces of a robot joint and the cascaded loops behind them.
  • Implement and tune a joint PID, and explain anti-windup and derivative filtering.
  • Explain why gravity compensation removes the need for large integral action.
  • Derive computed-torque control and state its sensitivity to model errors.
  • Explain impedance and admittance control and when each is used.
  • Measure overshoot, rise time, settling time and steady-state error from a response.

Conceptual explanation

A joint can be commanded at three levels. A torque (current) command sets the motor torque directly: it gives the most freedom, needs a good model, and is what collaborative and research arms expose. A velocity command closes a velocity loop in the drive. A position command closes position, velocity and current loops in cascade inside the drive, the usual interface of industrial robots. Inner loops run faster (current at about 10–20 kHz, velocity at about 1–4 kHz) than outer ones (position or trajectory at about 0.25–1 kHz).

Joint PID

Each joint is controlled independently, and the coupling from other joints and gravity is treated as a disturbance. The proportional term pulls the joint towards the reference, the derivative term damps the motion, and the integral term removes steady errors, for example the sag caused by gravity. Practical PIDs filter the derivative, apply it to the measurement rather than the error (no "derivative kick" at reference steps), and stop integrating while the motor is saturated (anti-windup).

Using the model

  • Gravity compensation adds the model's g(q)g(q) to the PID output, so the feedback loop only handles the dynamic errors.
  • Computed-torque control (inverse-dynamics control) uses the full model M,C,gM, C, g to cancel the nonlinear dynamics, leaving each joint as a double integrator controlled by a PD loop with the same response in every pose. It is excellent when the model is right and degrades when it is wrong.

Interaction control

Position control fights contact: if the tool touches a surface 1 mm before the program expects, a stiff position loop pushes as hard as it can. Impedance control makes the robot behave like a programmable spring and damper around its reference: it measures motion and commands force or torque. Admittance control does the opposite: it measures the contact force with a force/torque sensor and turns it into a motion of the reference, which a stiff position-controlled robot then follows. Impedance suits torque-controlled, backdrivable arms; admittance suits stiff industrial arms with a wrist force sensor.

Step-response metrics

  • Overshoot: how far the response passes the target, as a percentage of the step.
  • Rise time: time from 10% to 90% of the step.
  • Settling time: time after which the response stays within ±2% of the target.
  • Steady-state error: the remaining offset once the response has settled.

Mathematical formulation

Joint PID (derivative on the measurement)
τi=Kp,i ei+Ki,i∫0tei dt−Kd,i q˙i,ei=qr,i−qi\tau_i = K_{p,i}\,e_i + K_{i,i}\int_0^t e_i\,dt - K_{d,i}\,\dot q_i, \qquad e_i = q_{r,i} - q_i
PID with gravity compensation
τ=PID(e)+g^(q)\tau = \mathrm{PID}(e) + \hat g(q)
  1. τ=M^(q) v+C^(q,q˙)q˙+g^(q),v=q¨r+Kde˙+Kpe\tau = \hat M(q)\,v + \hat C(q, \dot q)\dot q + \hat g(q), \qquad v = \ddot q_r + K_d \dot e + K_p e

    Computed torque: cancel the dynamics with the model, then command the acceleration v.

  2. e¨+Kde˙+Kpe=0(if M^=M, C^=C, g^=g)\ddot e + K_d \dot e + K_p e = 0 \quad (\text{if } \hat M = M,\ \hat C = C,\ \hat g = g)

    The error obeys a linear, decoupled second-order equation: choose Kp = ωn² and Kd = 2ζω_n.

  3. e¨+Kde˙+Kpe=M^−1[(M^−M)q¨+(C^−C)q˙+(g^−g)]\ddot e + K_d\dot e + K_p e = \hat M^{-1}\big[(\hat M - M)\ddot q + (\hat C - C)\dot q + (\hat g - g)\big]

    With model errors, the right-hand side acts as a disturbance; with no integral term it leaves a steady error.

Target impedance (and admittance) behaviour
Md x~¨+Bd x~˙+Kd x~=Fext,x~=x−xrM_d\,\ddot{\tilde x} + B_d\,\dot{\tilde x} + K_d\,\tilde x = F_{\text{ext}}, \qquad \tilde x = x - x_r

An impedance controller computes F=Kd(xr−x)+Bd(x˙r−x˙)F = K_d(x_r - x) + B_d(\dot x_r - \dot x) and applies τ=JTF\tau = J^{T}F plus gravity compensation. An admittance controller integrates the target equation from the measured FextF_{\text{ext}} to obtain a modified reference xx for the position loop.

Diagrams

Computed-torque control loopThe reference trajectory gives desired position, velocity and acceleration. A PD law on the tracking error adds to the desired acceleration; the model M(q) scales it and adds the Coriolis and gravity terms to give the motor torque. Measured q and q-dot are fed back.Trajectoryq_d, q̇_d, q̈_dΣPD on errorKp e + Kd ėM(q) · ( )v = q̈_d + PD+Robot armreal dynamicsτC(q, q̇)q̇ + g(q)model termsmeasured q, q̇ (feedback)−
Computed torque: if the model is exact, the loop reduces to a linear error equation ë + Kd ė + Kp e = 0 for every joint. Removing the M(q) and model blocks gives plain PD; keeping only g(q) gives PD with gravity compensation.

Worked examples

Example 1: tracking a quintic move with five controllers

The 2R arm of Module 09 moves from (−90°,0°)(-90°, 0°) to (0°,90°)(0°, 90°) in 1.5 s, simulated for 3 s at 1 ms with a 500 Hz controller, torque limits of 40 and 20 N·m, and gains Kp=(60,30)K_p = (60, 30), Ki=(20,10)K_i = (20, 10), Kd=(6,3)K_d = (6, 3); the computed-torque loop uses Kp=100, Kd=20K_p = 100,\ K_d = 20.

Tracking errors in milliradians (1 mrad ≈ 0.057°). Simulated by the engine.
ControllerRMS error q₁ (mrad)Max error q₁Final error q₁RMS error q₂Final error q₂
PD (no integral, no model)123.2147.8146.928.09.1
PID84.9107.069.224.76.0
PID + gravity compensation19.241.10.59.11.5
Computed torque (exact model)0.10.30.00.70.0
Computed torque, masses 20% wrong36.948.248.242.552.9

Without an integral or a model, gravity leaves the shoulder sagging by 146.9 mrad (8.4°). The integral term removes part of it within the 3 s; gravity compensation removes it at once. With an exact model, computed torque tracks almost perfectly. With masses 20% wrong and no integral term, it settles with an error of about 48.2 mrad.

Example 2: rejecting a disturbance

At t=2t = 2 s, a 3 N·m torque pulse lasting 0.2 s hits the elbow (as if someone pushed the forearm):

Elbow response to a torque pulse.
ControllerPeak elbow error (mrad)Final elbow error (mrad)
PID + gravity compensation87.84.0
Computed torque (PD outer loop)552.34.4

The computed-torque loop multiplies its PD output by the elbow's small effective inertia, so its corrective torque is small and the push moves the forearm much further. The PID has fixed torque gains and resists more firmly. A good model improves tracking, but it does not replace feedback gain or an integral term.

Example 3: step-response metrics

A step from (−90°,0°)(-90°, 0°) to (0°,90°)(0°, 90°) with PID and gravity compensation (a step is harsher than any real reference):

Step-response metrics computed from the simulated response.
JointOvershootRise timeSettling time (±2%)Peak torqueTime saturated
111.9%0.145 s0.57 s40.0 N·m0.10 s
23.3%0.240 s2.31 s20.0 N·m0.01 s

Both motors hit their torque limits at the start: a step asks for more than the motors can give, which is why references are always smooth trajectories (Module 10).

Example 4: an impedance-controlled tool against a wall

Choose a target stiffness Kd=500K_d = 500 N/m and an apparent mass Md=2M_d = 2 kg, with critical damping Bd=2KdMd=63.2B_d = 2\sqrt{K_d M_d} = 63.2 N·s/m. If the commanded position lies 20 mm inside a rigid wall, the robot presses with F=Kd⋅0.02=10F = K_d \cdot 0.02 = 10 N instead of the full motor torque a stiff position loop would produce. An operator pushing the tool with 10 N displaces it by F/Kd=20F/K_d = 20 mm, and it returns without overshoot. (This example is analytic; the labs simulate free motion only.)

Interactive experiment

Interactive PD step response (needs JavaScript).

Tune Kp and Kd of a joint stepping to a new angle, with or without gravity compensation: the response, overshoot, settling time, steady-state error and damping ratio update live.

Real-world applications

  • Industrial arms run cascaded position, velocity and current loops in the drives, with feedforward from a dynamic model at higher speeds.
  • Collaborative robots use torque sensing and impedance control for hand guiding and gentle contact, and model-based collision detection.
  • Polishing, deburring and assembly use admittance or hybrid force/position control with a wrist force/torque sensor.
  • ROS 2: ros2_control exposes position, velocity and effort command interfaces; joint trajectory controllers track trajectories through them (see the ROS 2 bridge page).

Tune these controllers yourself in Lab 08.

Common mistakes

Fixing gravity sag with a huge integral gain

A large Ki causes overshoot, slow oscillation and windup. Add gravity compensation and keep Ki for what remains.

Forgetting anti-windup

While the motor saturates, the integral keeps growing and later causes a big overshoot. Stop integrating (or back-calculate) during saturation.

Differentiating a noisy encoder signal without a filter

The derivative amplifies quantisation noise; filter it or use the drive's velocity estimate.

Trusting computed torque with a wrong model

Payload or mass errors leave tracking errors and, without an integral, steady offsets. Identify the model and keep feedback robust.

Position-controlling into contact

A stiff position loop against a surface produces large forces. Use impedance or admittance control, or limit force and speed.

Key takeaways

  1. Drives offer torque, velocity or position interfaces built from cascaded loops.
  2. Independent joint PID works but treats gravity and coupling as disturbances; gravity compensation removes the largest one.
  3. Computed torque linearises and decouples the arm with an exact model, and degrades gracefully but measurably with model errors.
  4. Impedance (motion in, force out) and admittance (force in, motion out) control contact behaviour.

Knowledge check

Write an answer to each question, then reveal the explanation. Your answers stay in your browser.

Question 1

Why does a PD joint controller on an arm in a vertical plane leave a steady error?

Explanation

At rest the PD output is Kp·e, which must equal the gravity torque, so e = g(q)/Kp ≠ 0. An integral term or gravity compensation removes it.

Question 2

In computed-torque control with an exact model, what equation does the error satisfy?

Explanation

ë + Kd ė + Kp e = 0: linear, decoupled and identical in every pose.

Question 3

What does anti-windup prevent?

Explanation

The integral term growing while the actuator is saturated, which would cause a large overshoot once the error changes sign.

Question 4

When would you choose admittance control over impedance control?

Explanation

On a stiff, position-controlled industrial arm with a force/torque sensor, where you cannot command joint torques directly.

Question 5

A response reaches 112% of the step and stays within ±2% after 0.6 s. Name the two metrics.

Explanation

12% overshoot and a settling time of 0.6 s.

Practise it in the labs

Then test yourself in practice exercises and challenge mode.

References and further reading

  • K. J. Åström and T. Hägglund, Advanced PID Control, ISA, 2006.
  • N. Hogan, "Impedance control: an approach to manipulation, parts I–III", ASME Journal of Dynamic Systems, Measurement and Control, 107, 1985.
  • B. Siciliano, L. Sciavicco, L. Villani and G. Oriolo, Robotics: Modelling, Planning and Control, Springer, 2009, chapters 8–9.