Six Pearls Designs

Conceptualizing BoB Mk3

2011 February 20

This is a little late, considering that I've already assembled him, but I'm going to go ahead and at least log some of the design ideas before I forget them.


Mechanically, the goal was: simple. Since graduating and changing jobs, I've lost my daily access to machine tools. I even lost access to SolidWorks, so I had to design everything using Inkscape and hand sketches. The one great tool I had was access to my dad's laser cutter. To make the most of this, I wanted everything to be cut out of a single, flat plate. After a few trials, I was able to get everything aligned. Since you can already see pictures of the mechanical assembly, I won't bother posting anything like design sketches. I think I succeeded in designing something functional, elegant, and aesthetically pleasing. Plus the battery backpack is cute.


I really really wanted to make an analog version of this. I tried a couple years ago, but didn't have the capabilities to make it succeed. Then some MIT student beat me to it, but with larger batteries. While he definitely hurt my pride, he at least showed me complementary filters, which is a really cool filter that would make analog control feasible.

Since it's been a while since I got to make anything cool, I decided to go digital for this iteration of BoB. My plan is to implement a digital complementary filter and manually tune a PD loop that works "well enough" just so I don't forget what it's like to build robots. Then I want to try at least one of: machine learning and/or analog control.

In both the digital and analog case, the real trick is going to be getting an accurate measure of the angle using a gyroscope and accelerometer and some kind of filtering. The basic concept is to use a high pass on the gyro and a low pass on the accel with the same time constant so their sum comes out to the "true" angle. Here's a block diagram and the s-domain algebra from Professor Katie Byl's thesis that Charles Guan used.

complementary filter block diagram

It took me a while to figure out why the high-pass filter on the gyroscope looks exactly like the low-pass filter from the accelerometer. The 's' that would typically be in the numerator of the transfer function is cancelled by the integration required to get the angle from the angular velocity. In a strictly analog setting, we would put low pass and add these signals and call it a day. According to another one of Guan's resources, it looks more like this in code:

angle = (0.98)(angle + gyro * dt) + (0.02)(x_acc);

I'm going to consult my notes to make sure I get why this is what it looks like. I see the integration on the gyroscope, but I'm a little confused about why summing it with coefficients like this creates a low-pass filter. At any rate, this is supposed to give me a well conditioned angle measurement, which is probably one of the harder parts. Then I just need a "sufficient" model for the system and I can plug it into a few equations, which I also need to look up, to get a decent first step for coefficients on the control loop.


I realized that with this mechanical assembly, the unstable equilibrium angle won't be aligned with vertical for the accelerometer since the center of mass is not directly above the wheel axis. Luckily if I hang him by the wheels, I can measure the stable equilibrium angle which is just 180 degrees from the unstable equilibrium angle. Similarly, I think I can measure the standard (non-inverted) pendulum behavior and derive a pretty good model of the system. Just measuring the angle versus time I should be able to pull out the damping and moment of inertia. If I can measure something about the current/emf of the motors, I think I could even pull out the motor coefficients. I may only need to measure the damping with the motor leads shorted and isolated to fully determine the system, but I haven't done the algebra yet to make sure.