@beautifulsmall
A way to make a balancing robot stand still, is to use a state-feedback controller. Basiclly, what you do is to decide what "goals" you want to have for the system, like angle=0, (angle d/dt)=0, (angle-integrated)=0 and motorspeed=0. By measuring or estimating these values(or states) you make a proposional-controller for each of them, and sum up the result from each term and use this as the controlinput for the motors. This is essentially what kas has done when feedbacking the encoder data and the (estimated) derivative for it.
Usually, you want to take base in a mathematical model for the dynamics of the robot when using this approach, as the correct amplificationfactors can be hard to find. With this model you can use pole-placement or LQR-design and decide how you want the robot to react, and then(with a lot of luck) get it that way. If someone is interested, this side gived a good desciption of this methods. I also think there is an example of how to make model of a inverted pendulum(essentially a balancing robot).
http://wikis.controltheorypro.com/
This method(also called modal-controller) was our plan to use when making the balancingrobot at school. The problem is that we didn't have encoders on the motors, and therefor we tried to assume that the speed of the motors were equal to the input to the motorcontroller(speedservo principial). But as it turned out that the motors had a much bigger time-to-rise than we thought, this wasn't good enough. A solution could have been to use a estimator(as proposed here by psychoul) to estimate the speed of the motors. This again requires a mathematical model for the motors, which we didn't have.
The last update for this robot is that I have shortened is down to make it look more like a "normal" balancing robot, and I have now got it pretty stable using PID controller. Then I know it works The plan for this christmas is to update the mathematical model for the shortened version, try to find a how the motors behave and make some sort of an estimator for the motorspeed, to come around the lack of encoder. Can be interesting to see if it will work!
However, when reading your post, I get the impression that what you want the robot to do is to make it a goal to stand still, and then make it "discover" that this can only be achived by making the angle equal zero(or rather equalibrium). To achive this my guess is you will have to use some sort of a neural network or(as you mentioned) fuzzy logic or other adaptable algorithm. This is basiclly something that continuous udates the controller parametres and the equalibrium-angle based on how the system seems to act. This makes it possible to put a weigth on top of the robot, and thereby change the equalibrium angle and the dynamic of the robot, and the controller will automaticlly be tuned to cope with the change. Really cool! The arthour of this youtube video seems to be using a kalmanalgorithm to obtain dynamic equalibrium angle.
and another video of a inverted pendulum controlled using some sort of adaptive algorithm:
But as I have no experince with adaptive algorithms, what I have said on these few lines is pretty much all I know. Hope someone can jump in and write some complementary lines about this intriguing field :D!
Well, again I managed to do a lot of talk here. Hope someone can find some of it interesting. I have been working on projects like this for quite a time now, and I have made myself a lot of thoughts about the field of system control
@kas -> beautifulsmall
Yes, a codensnippet of some fyzzylogic would be great!
cheers!
Jon, Norway