• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Self Balancing Algorithms

Bodhi Dharma Zen

Advaitin
Joined
Nov 25, 2004
Messages
3,926
Has anyone here worked with algorithms designed to keep something in balance? for instance, robots standing on their feet, or driving bicycles, or the ones on the Segway...

I understand I need it to be sensible of its surroundings (an x/y graph) and to be able to react in order to keep balance..

Thanks!
 
I've done some experiments along these lines. You need to start with something to generate a sense of balance - typically a solid-state accelerometer and gyroscope that the robot can use to determine its orientation and acceleration. These have come down a lot lately, you can get a 6DOF acceleration/rate gyro package for under $100. The output of that goes into an onboard computer system that tracks the robot's current position and does some fancy math to compare its actual position and orientation to the target position and orientation, and work out the required movement of the wheels or legs to stay upright.
 
Check instructables.com -- I site-searched "segway" and found lots of stuff.
This one might be just what you're looking for:
http://www.instructables.com/id/ArduinoGyroscopeProcessing/
"This is an instructable on how to read a gyro sensor and plot the data using processing software at your desktop. I am using gyroscope model XV81-000 and an arduino. The device is a rough prototype of what will eventually become a self balance robot, this is the first part of the hole thing (read accelerometer and control a motor to self balance)."​

Be sure to read the article's comments section, too.
 
Thank you all for the answers. I need the algorithm to work with data, that I already have, so in other words I'm just looking for the appropriate coding.

ellindsey,

what about that fancy math... is it prebuilt? or can you access the code?
 
Worm-like robots don't need to balance.
They just scoodge along, minding their own business.
 
Thank you all for the answers. I need the algorithm to work with data, that I already have, so in other words I'm just looking for the appropriate coding.

ellindsey,

what about that fancy math... is it prebuilt? or can you access the code?

What does your data look like and what do you want to do with it? I am not certain that any pre-recorded information can be used to balance an object, since the act of balancing it would influence how the data would look like.

FWIW I once built a primitive LEGO Mindstorms balancing robot - think unicycle. Dead simple. I included a free-swinging pendulum that was facing down, read out the angle between the weight/pendulum and the robot and then let the robo drive forward or backwards to try and gets its one wheel directly underneath the pendulum. Surprisingly, it worked out fairly well!
 
What does your data look like and what do you want to do with it? I am not certain that any pre-recorded information can be used to balance an object, since the act of balancing it would influence how the data would look like.

the data is being generated in realtime and I run a series of algorithms on it, then I read the results of those algorithms and I want to apply a self balancing algorithm to those results in order for the first algorithms, running on the original data, to adapt.
 
Here's a guy that built his own Segway, along with the pseudocode for the controller. At the bottom of the page he has links to other, similar experiments, and they in turn have lots of links....

http://tlb.org/scooter.html

My impression, with no proof whatsoever, is that balancing on wheels is a lot easier than on legs. But, considering that walking is controlled falling, that makes a lot of intuitive sense.
 
Last edited:
Here's a guy that built his own Segway, along with the pseudocode for the controller. At the bottom of the page he has links to other, similar experiments, and they in turn have lots of links....

http://tlb.org/scooter.html

My impression, with no proof whatsoever, is that balancing on wheels is a lot easier than on legs. But, considering that walking is controlled falling, that makes a lot of intuitive sense.

Depends on how many legs you've got.
 
Here's a guy that built his own Segway, along with the pseudocode for the controller. At the bottom of the page he has links to other, similar experiments, and they in turn have lots of links....

http://tlb.org/scooter.html

My impression, with no proof whatsoever, is that balancing on wheels is a lot easier than on legs. But, considering that walking is controlled falling, that makes a lot of intuitive sense.

Thank you for that link! it has some rudimentary instructions for the coding..
 
Thank you for that link! it has some rudimentary instructions for the coding..
Click the link at the top of the page for the unicycle and he provides a link to download the software. I suspect that if you contacted him he'd provide you with the software for the 2 wheeled varieties.
 
Wouldn't the stability augmentator systems used on aircraft effectively do the same thing? Sense undesired movement, then input a correction to stabilize the object?

As I understand it our nervous system makes all sorts of adjustments all the time in order to keep us standing right.
 
Thank you all for the answers. I need the algorithm to work with data, that I already have, so in other words I'm just looking for the appropriate coding.

ellindsey,

what about that fancy math... is it prebuilt? or can you access the code?

What are you programming in? A lot of college electrical feedback courses have students do exactly that. Basically you are going to be putting more of an emphasis on position than speed/acceleration on the control
 
Wouldn't the stability augmentator systems used on aircraft effectively do the same thing? Sense undesired movement, then input a correction to stabilize the object?

As I understand it our nervous system makes all sorts of adjustments all the time in order to keep us standing right.

yes thats what I need it to do, to "sense" the undesired movement and then stabilize it around the accepted parameters

What are you programming in? A lot of college electrical feedback courses have students do exactly that. Basically you are going to be putting more of an emphasis on position than speed/acceleration on the control

Its called "Easy Language", the output is the result of a code running on the signal, and I want another system to keep an eye on the first code in order for the output to remain constant.
 
<snip>

As I understand it our nervous system makes all sorts of adjustments all the time in order to keep us standing right.

It's the cerebellum which handles the fine tuning of motor activity. The rate neurons can 'fire' in this region of the brain is quite impressive at well over 100 times a second.
 
When I was in Engineering School, I found a lot of books that talked about an "inverted pendulum," and some books included pretty detailed specifics about how to build one. Although I built a snazzy motor controller, I thought it might be kinda fun to build an inverted pendulum or other balancing apparatus, especially one that could stand up to a lot of disturbance and still not fall over. Never did, though. It would be a great science demo, and I imagine that it could be adapted interactive use in a museum of science and technology ... but I've never seen one.
 

Back
Top Bottom