Engineering
Serial robot
Send a three-link arm with a 10 kg payload from one pose to another along a quintic path: each joint’s PD controller with gravity feedforward follows within a few centimetres, and the shoulder torque at rest is exactly the sum of weight times horizontal lever arm beyond it, largest with the arm stretched out. Halve the torque limits and the shoulder can no longer hold the extended load, so the arm drops; switch the gravity feedforward off and it droops by the gravity moment over the gain; add payload and watch the shoulder approach its limit; ask for a point beyond the reach and the arm stays. Motor work is booked against kinetic and potential energy and joint friction.

What happens
A three-link planar arm of 0.5, 0.4 and 0.2 m with point masses of 12, 8 and 3 kg at the link ends and a payload at the tool. The mass matrix, the Coriolis vector and the gravity vector come from the Jacobians of the point masses; each joint is driven by a PD controller with gravity feedforward and a torque limit, viscous friction at the joints, an analytic elbow-up inverse kinematics and a quintic straight-line path from the start pose to the end pose. RK4 at 0.2 ms; the motor work meets the change of kinetic and potential energy plus the friction to rounding, and the static joint torques are the closed-form gravity moments of the masses beyond each joint.
Try this
Watch the arm carry the payload along the path and read the shoulder torque against the gravity moment; halve the torque limits and the arm drops; switch the feedforward off and it droops; aim beyond the reach and it stays.
The model and its limits
A planar arm with point masses, ideal joints without backlash or motor dynamics, PD control with a torque clamp, no collision with itself or the floor. Torques and errors are those of this idealized arm.
Equations used in the module
Equations M(q)·q″ + h(q, q′) + g(q) = τ − b·q′ M = Σ m_k·J_kᵀ·J_k, g_j = Σ m_k·g·∂y_k/∂q_j = Σ_(k≥j) m_k·g·(x_(k+1) − x_j) τ_i = clamp(K_p·(q_i* − q_i) − K_d·q_i′ + g_i(q*), ±τ_max) cos q_2 = (w² − l_1² − l_2²)/(2l_1·l_2), s(u) = 10u³ − 15u⁴ + 6u⁵


