Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Canada
Asked — Edited

2 Wheel Balancing Robot

I got a 4 - in - 1 sensor and have put together a 2 wheeled balancing robot. Now I need to figure out some coding. I have the Initialization script and it works good - getting lots of data. I'm not having any luck after that. Does anyone have some scripting they would be willing to share with me to help me get going?
Here's what I've got so far.

Code:


ControlCommand("MPU9150", Init)

sleep(100)

:loop
#Added these because $AccelX and $AccelY were not recognized later in the script for some reason.
$XAccel = $AccelX
$YAccel = $AccelY

if ("x" =0)

print(1)

sleep(2000)

goto(loop)

endif

ControlCommand("MPU9150", RunOnce)

if($AccelX > 1000 and $AccelX < 1000)
servo(d4,108)
servo(d6,108)
endif


print("x: " + $XAccel)
print("y: " + $YAccel)

if($AccelX > 1000)

servo(d4,120)
servo(d6,61)


print(2)
elseif ($AccelX < 1000)
Servo(d4,61)
servo(D6,120)

print( 1)
endif
Sleep(100)
goto(loop)

I am working with a code that d. cochran posted awhile ago.
It will change directions when it is tipped but will never stop. Also, after it has run for 30 seconds or so it will just keep running and the only way to stop the wheels is by disconnecting the power to the EZB.

#24  

Quote:


I type in "balance" and in drop down menu it shows self balance robot.

Maybe a difference in the mobile web interface vs full interface. I was searching from my phone, and had no luck.

Interesting looking device now that I found it. A bit pricey for what it does, but this is not a cheap hobby....

Alan
#25  
@proteusy - on YouTube search for husarion robot . You should find a few videos on their stuff.

@thetechguru - not a cheap hobby at all, but it was cheaper that my main hobby of drag racing Mustangs. There are a few pretty decent self balancing robots out there.
PRO
Synthiam
#26  
There are a number of awesome self balancing robots out there - and they're pretty neat to see. Balancing robots are quite simple and that's not an issue with EZ-Robot's inverted pendulum, as you can see from this inverted pendulum test from last year...



However, the challenge ez-robot is taking on isn't a simple balancing robot. EZ-Robot's inverted pendulum is taking the challenge to make anything inverted balancing. Meaning a selection of motors, wheel sizes, hbridges (for differing motor sizes), voltage, and robot sizes.

The reason that above video is working with the inverted pendulum prototype is that the pid and algorithm is tuned for the voltage, hbridge, motors, wheel size, and weight.

The idea of the inverted pendulum is to provide easy options to the user to very simply fine tune an inverted pendulum balancing robot that was built within the range of hardware specifications.

The reason i'm looking at other balancing robots is because everyone does the pid and other work within the main loop a little different - and i'd like to learn what others are doing to assist with our goal. Sadly, all of the open source code that i have seen is either very inefficient or only works due to pure fluke because sometimes the PID's don't even make sense. Those with professional knowledge of programming can view the code and see unused variable declarations, re-assigning variables with nullifying previous calculations, and a pile more.

But - that doesn't mean EZ-Robot giving up on the inverted pendulum:D We've been interviewing some math professionals to grow/fix/enhance the algorithm i've been working on.
#27  
Thanks for the update DJ, the robot in your video is what I was wanting to create, but as I've said before, I had not idea of the complexity of it. Good luck with your Inverted Pendulum.
#28  
I don't get the appeal of two wheeled robots and having to use all this self balancing effort to make them work. It's a neat technical challenge, but of what practical use is it? It must be a power hog, what with having to make constant corrections to maintain balance. Just add one or two wheels or casters and away you go. It could still have the same turn radius and all. I saw the Segway as the same sort of thing. More of a gimmick than a practical solution to anything. So, what exactly is the advantage of a two wheeled self balancing robot?
PRO
Synthiam
#29  
Ezeobots interest in any robot technology is to provide a platform for learning. What you do with it is your own reasons:)

I think the balancing action is neat and ppl r curious about it... that's probably the only interesting part lol
#30  

Quote:

So, what exactly is the advantage of a two wheeled self balancing robot?


For me it is because it looks cool, which improves the WAF (Wife Acceptance Factor). My wife has been much more supportive of my robot supplies purchases and the time I spend on them since I got a Six. Six is the most useless of my robots, but looks and moves the coolest, so she understands why I want to build them. If I could build a balance bot, it would amaze her, and I would have another year of high WAF.

Alan
#31  
For me, it's like a good challenge and the kids are interested in it also. I have some friends at CMU (PA) and I had the chance to pick their brains. R. Hollis and G. Kantor (and some others) are very talented and they put me to shame.

@DJ, just don't tap it, push it. Are you using a cascading PDI?
#32  
@DJ here some of my samples, please let me know once you view them. All three use different software and hardware. I have one of Ralph also, but ran out of time.

Yours looks like it may be using SainSmart stuff? Could be wrong.

PRO
Synthiam
#33  
Thanks! I really really enjoyed those videos!
#34  
I am going to be doing some acrylic laser cuts of the last one, if you interested in a set let me know and maybe we work out a deal.
PRO
Synthiam
#35  
That will be neat to see an acrylic version of that bot! Looking forward to it
PRO
USA
#36  
cool!

The last one is very crafty (wood details).

@DJ,
Does yours works without encoders ?

Most of them use encoders, i don't know if is a requirement to handle the balance or not.
PRO
Synthiam
#37  
Yes and no.

If there are no encoders, the encoder pid is disabled.
#38  
Just my opinion and I am sure a lot of effort has gone in to building and programming these (kudos), but after about 10 minutes the novelty for me is gone... I say save you battery and the need for extensive processing power and add a 3rd castor wheel.... KISS for reliability and efficiency. Practicality wise balancing bots are for show only...
PRO
Synthiam
#39  
They sure show well! Sure, practicality isn't the strong point of a balancing robot yet, but when we (ezrobot) gets a universal inverted pendulum module reliable... imagine the applications. We could slowly start getting increased reliability and stability out of balancing robots. Who knows, maybe one day they'll all balance on two wheels:D

Heck, humans have made it pretty far balancing on two feet!
#40  
@DJ.... Does the inverted pendulum off load some/all of the processing power in order to balance the bot? I am all for that if the ezb isn't bogged down just maintaining balance....
PRO
Synthiam
#41  
Yeah - that's exactly what the purpose of it is
#43  
Oh and don't forget about OldBotBuilder and his Lego EV3 / EZB4. This will be the last of me participating here. You can find me on twitter if any questions.