Single-joint arm with a torque-limited motor
Rotational Newton's law I·α = Σ τ for a robot link. Gravity torque depends on angle, a motor has a torque limit, and a PD position controller droops under load or fails outright when the motor is too weak.
What it demonstrates
Rotational Newton's law I·α = Σ τ for a robot link. Gravity torque depends on angle, a motor has a torque limit, and a PD position controller droops under load or fails outright when the motor is too weak.
How it works
The link is a uniform rod pivoting at one end, so I = m L²/3 and its centre of mass sits at L/2. Gravity produces τ_g = −m g (L/2) sin θ, with θ measured from hanging straight down. Joint friction is viscous, −b·ω.
In direct-torque mode you set the motor torque. In PD mode the motor is asked for τ = Kp(θ* − θ) − Kd·ω, the same structure as the low-level joint controllers on legged robots. Either command is clipped to ±τ_max before it reaches the link, then α is integrated with semi-implicit Euler at 1 kHz.
Adjustable parameters
- Command mode: PD position or direct torque
- Torque command (−8 to 8 N·m)
- Target angle (−180° to 180°), Kp (0–60 N·m/rad), Kd (0–3 N·m·s/rad)
- Motor torque limit (0.5–10 N·m)
- Link mass (0.3–3 kg), length (0.25–1 m)
- Joint friction b (0–0.5 N·m·s/rad)
Known limitations
- The motor is ideal below its limit: no delay, no speed-dependent torque drop, no gear backlash or rotor inertia (armature).
- One joint. Multi-link arms add Coriolis and coupling terms, C(q, q̇) in the chapter's equation.
Equations
Core update rule
tauReq = mode === "torque" ? tauCmd : kp * (target - theta) - kd * omega;
tauMotor = clamp(tauReq, -tauMax, tauMax);
tauGrav = -m * g * (L / 2) * Math.sin(theta);
alpha = (tauMotor + tauGrav - b * omega) / (m * L * L / 3);
omega += alpha * dt;
theta += omega * dt;Explained in Chapter 2: Physics Engines