Inverted pendulum
An arm on my desk that swings itself upright and balances there. One motor, no hands. The next one has two arms and still only one motor.
The problem
Hang a pendulum below its pivot and it looks after itself: push it, and gravity brings it back. Stand the same arm above its pivot and gravity does the opposite — the further it leans, the harder it is pulled over. Only which side of the pivot it is on has changed.
One link, driven at the shoulder — θ measured from hanging
$$I\ddot{\theta} = \tau - b\dot{\theta} - mgL\sin\theta$$Two places it can sit still — only one of them stays
$$\sin\theta = 0 \;\Rightarrow\; \theta = 0 \;\text{(hanging)} \quad\text{or}\quad \theta = \pi \;\text{(upright)}$$So the motor has to notice a lean and undo it faster than that runs away. Mine reads the angle and decides 200 times a second. The sensor, the loop rate, the friction I keep re-measuring — all of it serves that race.
In simulation first
I do not know the machine exactly — some numbers are measured, some estimated. So I simulate a few hundred versions of it and ask how many stay up. A controller that only works on the machine I assumed is no use.
Then on the bench
The same app drives the simulator and the real rig, and the corner tells you which. Telling those two apart is most of what I write about.
What I wrote about it
Newest last, which is roughly the order the work happened in. More will follow as the second arm gets built and measured.
What’s next: a second arm
Add a second arm, hinged onto the first, with no motor at the new joint. The shoulder must swing both up and hold them there through a joint it cannot push on.
Two links, one input — B selects the shoulder alone
$$M(q)\,\ddot{q} + C(q,\dot{q})\,\dot{q} + g(q) = B\,u$$ $$B = \begin{bmatrix} 1 \\ 0 \end{bmatrix}$$The plan: linearize about upright and solve for the gains
$$A^{\top}P + PA - PBR^{-1}B^{\top}P + Q = 0$$ $$K = R^{-1}B^{\top}P$$Not built yet
Those gains are only as good as the numbers inside A and B, which come from a plant model I am still calibrating. Solving it now would return confident, plausible, wrong answers.
