Step 2
Force, torque & gravity
Work out the torque each motor needs to hold the arm up, then hold three poses with nothing else.
Torque: a turning force
A door swings easily from its handle, hardly at all near its hinges. A force (newtons, N) acting a perpendicular distance (metres) from an axis makes a torque
(tau) is in newton-metres (N·m); is the lever arm. Here nothing holds the arm up unless your torques do.
Gravity on the arm
Gravity pulls each link down with its weight , where is its mass (kg) and m/s². The weight acts as if it all hung from one point, the link's centre of mass. It pulls straight down, so only horizontal distances are lever arms.
A joint carries every link beyond it. To hold them still its motor must give
where adds up over every link the joint carries, is that link's mass, the horizontal position of its centre of mass and that of the joint, all measured forwards from the shoulder. Gravity tips a mass in front of the joint forwards, so the motor pushes back: hence the minus sign.
Finding the positions
The shoulder, elbow and wrist angles are measured from straight up and add along the arm, so the links tilt by , and . A length at tilt reaches forwards. So the elbow is at , the wrist at , and the forearm's centre of mass at , with from the table.
| Link | Mass | Centre of mass from its joint |
|---|---|---|
| upper arm, m | 0.6032 kg | 0.0968 m |
| forearm, m | 0.3560 kg | 0.0791 m |
| wrist + hand | 0.1519 kg | 0.0295 m |
| payload | 0.3 kg | 0.06 m past the wrist |
The payload is one more mass: every joint that carries it needs its weight times its lever arm too.
The PID control problem meets this torque without a model: its I term has to find it.
Your task
Write gravity_torques(q): the torques [0, τ1, τ2, τ3] that hold the arm still at q (gravity can't turn the base: its axis is vertical). The program glides to three poses and holds each for 1 s with only your torques. The arm must drift less than 1°, and your function must match the simulator within 2 % on random poses.