Skip to the content
FixTheRobot Explore Robotics / Manipulator Basics / Labs / Lab 08

Manipulator Basics · Lab 08 of 10

Lab 08: Manipulator Control

Tune joint PID, add gravity compensation, try computed torque and reject disturbances on a 2R arm with real dynamics.

Objective

Close the loop on a 2R arm with real rigid-body dynamics: tune joint PID gains, add gravity compensation, compare position, velocity and computed-torque control, inject disturbances and measure overshoot, settling time and steady-state error.

Brief theory

The arm obeys M(q)q¨+C(q,q˙)q˙+g(q)+Bq˙=τM(q)\ddot q + C(q,\dot q)\dot q + g(q) + B\dot q = \tau (Module 09). An independent joint PID computes

τi=Kp,i ei+Ki,i ⁣∫ei dt+Kd,i e˙i,ei=qr,i−qi\tau_i = K_{p,i}\,e_i + K_{i,i}\!\int e_i\,dt + K_{d,i}\,\dot e_i,\qquad e_i = q_{r,i} - q_i

Gravity compensation adds the model’s g(q)g(q) as a feedforward, so the PID no longer has to hold the arm up. Computed-torque control cancels the whole model: τ=M^(q)(q¨r+Kde˙+Kpe)+C^q˙+g^\tau = \hat M(q)(\ddot q_r + K_d\dot e + K_p e) + \hat C\dot q + \hat g; with a perfect model the error obeys e¨+Kde˙+Kpe=0\ddot e + K_d\dot e + K_p e = 0. Velocity control here is a cascade: an outer position loop sets a joint velocity reference and an inner PI loop tracks it. See Module 11.

Simulation workspace

Drag in the view where the controls say you can. Every number shown is computed live by the simulation engine running in your browser.

Loading the simulation…

Guided tasks

Each task ticks itself when the simulation sees you do it. Progress is saved in this browser.

  1. Tune PID parametersChange at least one gain and run the simulation.
  2. Track a desired trajectoryUse the quintic reference and get the RMS tracking error of both joints below 0.02 rad.
  3. Introduce disturbancesEnable a disturbance torque pulse and run.
  4. Compare poorly tuned and well-tuned controllersRun twice with "Keep previous run" on so both responses are overlaid.

Challenges

Each challenge states an objective, its constraints and how success is measured. The live line under it is computed from the simulation. Hints and full solutions are there when you want them.

Success criteria

  • Metrics are measured from the simulated response, not estimated: overshoot, 2 % settling time, steady-state error, RMS error, peak torque and control effort.
  • Tracking RMS below 0.02 rad on both joints with torque limits respected.

Explanation of the results

Without gravity compensation, a PD controller holds the arm only by keeping an error large enough that Kpe=g(q)K_p e = g(q): that is the steady-state error you see, and it shrinks only as KpK_p grows. Integral action removes it slowly and adds overshoot; gravity compensation removes it immediately, if the model is right. Computed torque tracks almost perfectly with the exact model and degrades as the model error grows: try the model-error slider.

Assumptions of this simulation. Two rigid links in a vertical plane, uniform rod inertias, viscous friction only, no motor electrical dynamics, no gear backlash or elasticity, torque saturation at the limits shown, a controller sampled every 2 ms with exact joint angle and velocity measurements, physics integrated with RK4 at 1 ms. Real joints add friction, flexibility, sensor noise and delay, which limit how high the gains can go.