How to control an underactuated platform with a single servo

What's the best way to control the following type of platform so that it remains balanced and upright?

It's a box supported by a single leg that can pivot at the foot (F) and at the hip (H). The foot and hip joints are designed so that they can only rotate in the xz plane (where x goes left-to-right and z goes up-and-down). It's similar in concept to the inverted pendulum, except the base (F) is fixed, and the actuation is done by shifting the mass at the "top" of the pendulum. I've seen some academic papers refer to this as the "cart-table model".

The hip joint is powered by a servo motor which can report its angle of deflection relative to the box (ϴⱼ).

At the center-of-mass (COM), there's an accelerometer that reports the box's angle of deflection relative to gravity (ϴᵢ).

I've constructed this platform and I'm now trying to program a microcontroller to actuate the servo so that the platform remains both upright and level.

The figure depicts the four basic states that the platform will experience. At t₀, it's perfectly level, but in an unstable leg configuration so that its center-of-mass is off-center and will cause it to begin toppling over.

At t₁, the platform has tipped forward slightly. I've been able to program my controller to detect this and start actuating the servo to rotate the box counter to the angle of deflection so that the center-of-mass shifts to the other side of the leg, taking me to state t₂.

However, this is where I run into problems. I'm using a simple PID controller that's being told the target value of ϴᵢ, while being fed the current value of ϴᵢ, and it's attempting to output a servo control signal to achieve this correction. After some testing, I realized this doesn't work because ϴᵢ isn't the only angle that needs to be controlled. By only looking at ϴᵢ, I was seeing massive oscillations of the servo all while the box topples over, because as soon as the servo tilted the box over the foot, ϴᵢ was then horribly unbalanced in the opposite direction, causing the PID controller to again correct it by shifting the box back over the foot...in the direction that the platform is falling, which only hastens the fall. I'm not sure how to tell the controller to "ignore" the unbalanced ϴᵢ once the center-of-mass has been shifted.

So I think the solution is that I need to either directly measure ϴₖ, or infer it by using ϴᵢ and ϴⱼ, and then feed both ϴₖ and ϴᵢ into my controller. However, I'm only familiar with simple PID controllers that take a single input. What type of controller would I use to take two inputs and output a servo signal?

If I input ϴₖ into my PID controller, I could probably get my platform to stop toppling over, but the box wouldn't be level. It would achieve a state close to that shown at t₂, where the box is skewed but its center-of-mass is balanced.

Would another solution be to re-locate the accelerometer to point H? If it were there, I could use the raw acceleration readings to get a reliable sense of when the platform has stopped shifting in the wrong direction, and use that period to temporarily disable the PID controller so it doesn't erroneously un-shift itself.

My goal is to get the platform to the state depicted in tₙ, where the box is level and the leg is angled so that the center-of-mass is evenly distributed so that the platform can remain upright. What type of controller would I use to accomplish this? Is there anything else I'm missing?

Edit: Updated the figure to depict the state described by @fibonatic.

• $t_n$ still does not look like a stable equilibrium, since the reaction force acting on the box doesn't go through the center of mass. Namely I suspect a stable equilibrium to be when both the center of mass and the pivots in the foot and hip are aligned vertically. – fibonatic Mar 31 '18 at 10:15
• @fibonatic Aligning all the pivots with center-of-mass would definitely be stable, but intuitively, I think tₙ should also be an equilibrium. You should be able to verify this empirically with a simple test. If you stand up and try to balance on your heels while bending forward slightly, you can still stay balanced even though your center-of-mass, hips, and feet are not in alignment. No? – Cerin Mar 31 '18 at 17:31
• I initially misread your question and thought that the actuator is in the foot instead of the hip. In that case $t_n$ would also be an equilibrium point, but would require a constant torque. – fibonatic Mar 31 '18 at 18:07