Balboa balancing algorithm

I don’t yet have experience with Balboa. I have a Balboa to be delivered this week. I have reviewed all of the blog posts and most of the code. I’m curious as how the balancing control algorithm evolved from a technical approach point of view.

Hi!

I think this post explains most of what I was thinking when I developed my balancing algorithm, but I’m sure there are a lot of other ways to do it.

What questions do you have about it?

-Paul

Paul, thanks, I’ve read through all of these Blboa blog posts several times. I’m curious what was your overall thought process on the balancing algorithm. Did you (I see that you have a PHD in physics) have the total understanding of the balancing algorithm theory before you started on the code implememtation? Or was it a bit more exploratory from one point to the next (as described in the part 4 blog post)? The algorithm looks like it executes very well, yet is not intuitive (at least not) to me at this point. One specific detail that I didn’t see via code inspection, is whether or not there is a minimun PWM for the motors to go from zero to start turning. Essentially the inititial non-linear startup of the motors.
Also, I noticed that the Balboa balances not exactly at 0 degrees vertical, but say a few degrees, say 5 degrees from vertical; how significant is this balance point for the balancing algorithm.
Thanks,
Chris

It’s hard for me to remember, but I don’t think I had much of an idea of where I was headed when I started out. I just knew that with so many variables involved, it would be really hard to just guess a complete solution like you can with a simpler PID system. So I thought it would help to first understand some of the dynamics. I always prefer to sketch out a graph or diagram instead of staring at equations, so I made plots like the ones in the post to study how the angle and rate of rotation change over time and how they might be affected by forces from the motors.

I didn’t take into account any kind of minimum PWM at all. I suppose that could be a future improvement, though it’s hard to know what to do about it.

As for estimating the balancing angle, if you go back a couple of posts to where I talk about the `angle` and `angleRate` variables you’ll see that I’m not using any kind of absolute measurement. The code just assumes that since the robot is not falling over, the average angle must be zero. So that’s one thing I didn’t have to calibrate, saving a lot of trouble. I do use an estimate of the starting angle when it’s lying down, but that can be pretty rough.

In the end, by understanding the dynamics of the system and focusing on what actually matters, I just had a couple of constants to adjust, and I kind of understood the effects of those constants, which made it possible to get something working with a short series of tests.

1 Like

Very interesting process. Thanks again.

1 Like