I'm proud to introduce you to... Arduway, a robot made of Arduino and Lego NXT components.
I'm releasing soon a software library to control LEGO NXT motors and a few sensors I have used: it's not as well documented as it could but I think it will still be better than nothing...
The drift is not evident in the first moments of functioning so it was satisfying enough for our purpose.
I tried anyway to correct it (to make the robot stand up hours and hours) using a band-pass filter (instead of an integrator) but it was not working as well as one would expect.
...Are you aware of any other method?
It would certainly be better not to have to integrate: this would avoid the integration drift.
As a conclusion... if you're thinking of creating your own Arduway think of replacing the gyroscope with a compass that directly returns the angle.
To do it right, it sounds like you need an accelerometer, too. David Anderson provides a pretty detailed description of how he did this on his nBot web site
He explains, "The gyroscope and accelerometer are combined with complementary filters to provide an inertial reference sensor. The ADXL202 accelerometer provides accurate static tilt information, when the robot is not accelerating. The gyroscope can be integrated to provide accurate dynamic tilt information, but the integration tends to drift over time. Combining the two sensors provides a robust inertial measurement."
But, there are apparently a number of different ways to make a balancing robot. I've heard of at least one person who managed to do it using distance sensors to figure out the tilt based on the distance of the sensor to the ground.
That's interesting!
Very nice idea (and very nice implementation!).
In my opinion an angle sensor can be enough (it certainly is enough in Matlab simulations).... and it is certainly less expensive than two sensors (BTW, I'm saying that because cheapness was one of the aim of the project).
The robot works pretty well even with only a gyroscope... if you start your own project keep in mind that an angle sensor (or maybe gyro + accelerometer) is better.
Well done,
Its a really nice project and great platform for control scheme design.
I have one question if you don't mind me picking your brain. How did you do the numerical integration? On the arduino itself? or integrate the signal before the arduino a/d?
If on the arduino what algorithm did you use? and what time step did you use?
The integration happens inside Arduino.
I preferred not to do hardware integration because I hoped that software could give me more flexibility.
I chose the fastest sampling time I could, which is 4 ms (--> 250 Hz).
I first used the rectangle method for integration but now I've preferred the trapezoid method to minimize the error: what I've found out is that most of the error comes from (1) the sensor and (2) ADC approximation.
Anyone going to replicate this robot should use an angle sensor (maybe I2C based) instead of a gyroscope; integration is bringing avoidable error.