ⓘ Reaction Wheel Pendulum PID Feedback Stabilization
The control input is the torque τ(t) applied by the motor on the reaction wheel (flywheel) located at the tip of the rod. This generates a reaction torque −τ(t) on the pendulum arm itself.
The feedback controller stabilizes the pendulum angle using:
τ(t) = − ( Kp·e(t) + Ki·∫e(t)dt + Kd·de(t)/dt ), where the angle error is e(t) = θ* − θ(t).
Note that Kp must be greater than the gravity factor (ag) (default 1.5 N·m/rad) to stabilize the upright vertical position. Because the flywheel's velocity is uncontrolled in this single-loop angle PID structure, any steady-state gravity offset will force the flywheel to continuously accelerate, causing it to spin at higher and higher speeds!