tirsdag den 5. oktober 2010

Lesson 4

Self-balancing robot

In this session we tried to build a self-balancing LEGO robot, using the original Steve Hassenplug's Legway, Philippe Hurbain's NXTway, and Brian Bagnall's balancing robot as inspirations.

The robot is standing on two wheels as a Segway, and must try to reach a stable position, by measuring the distance from the light sensor (see the picture) to the floor.
To perform this we used the PID-controller 'Sejway' written by Brian Bagnall, which computes the power to inject into the motors by a combination of a proportional error, an integrative error and a derivative error. As the code was already written, the most difficult part was to find the good settings for the offset and the P-, I- and D-coefficients.


Interactive menu.

In order to make the experiments easier, we made all those settings interactively configurable, using the NXT's buttons and screen. Then we could modify the settings while experimenting, without reloading the program each time. For a smooth usage, a long push on the left or right button makes the values change continuously. As this interactive menu is managed by a class listening all the buttons of the NXT, the program was first not stoppable anymore. We fixed this by making a long push (>1s) on the grey button stop the program.

After many trials, we managed to keep the robot standing 5s... impressive!

Ingen kommentarer:

Send en kommentar