Dynamics & Torque Control, step 4
Computed torque
Use the model to supply the torque a fast motion needs, so feedback only fixes small errors: tenths of a degree where PD lags by degrees.
Builds on Mass, inertia & F = ma, from the free Foundations.
Write and run this step in the simulator with ProWhy PD lags
Feedback only pushes once an error has appeared. On a fast move, PD + gravity has to fall behind by a sizeable error before it makes the torque needed to accelerate, so it lags by degrees unless its gains are made harshly stiff.
Inverse dynamics
Step 1 predicted motion from torques. Turned around, the equations of motion give the torques that produce a chosen acceleration :
This is inverse dynamics.
Computed torque
Choose the acceleration from the trajectory, plus corrections for errors:
, and are where the trajectory wants the arm now, and how fast and how hard it is accelerating. Substitute into and the arm's own dynamics cancel: . Every joint's error then obeys
the same well-damped spring in every pose, at every speed. (1/s²) and (1/s) are gains on accelerations, not torques: turns them into the right torque for each joint.
Feed-forward and feedback
Split the torque in two. is feed-forward: what the motion needs, known before anything goes wrong. is feedback: the correction. The program plots both at the shoulder; the feed-forward does nearly all the work.
The program
The arm sweeps out from A to B and back, 0.5 s each way. It runs once with PD + gravity, gains scaled for a typical 0.1 kg·m² joint, and once with your controller. Plots shows both errors.
Your task
Write inverse_dynamics(q, qd, qdd), then computed_torque(q, qd, q_des, qd_des, qdd_des) using it. Both are checked on 8 states, and your controller must keep every joint within 0.5° of the sweep.