Thursday, 8 March 2012

Legolab 5

Legolab 5
Date: 01-03-12
Duration: 3 hours
Group members attending: Tore, Troels & Kristian

Goal
The goal for today is to build a legway, using the light sensor to control the distance and make the robot balance from the input.

Plan:
1. Build the new robot according to the images(*1).
2. Convert the code so it fits the new version.
3. Setup blue tooth connection between computer and robot.
4. Configure the PID constants.


Execution of the plan
1. We used the photos at the buttom of the page (*1) to build our own legway. We have used larger wheels, thinking it would be easier to balance on big wheels. With small wheels, however, it is probably easier to make small corrections in the direction. We might change wheels later. Our legway is seen in the image below:
2. This was just some simple corrections so the code can run on the new version, as seen below:

if (pid_val > 0) {
          MotorPort.B.controlMotor(power, 1);
          MotorPort.C.controlMotor(power, 1);
      }
     else {
          MotorPort.B.controlMotor(power, 2);
          MotorPort.C.controlMotor(power, 2);
      }

3. We got bluetooth working with the robot and paired it with our computer. BTCarController won’t connect to the robot, so we just manually upload the program every time we try out new values.

4. We tried to adjust the kp,ki and kd constants (from the article on PID controllers (*2)), basically just by trial and error. After a few tests, we realized that when holding the robot at the start, our arms shadowed the table, and we got a wrong value for the offset. Most times the legway would balance a few seconds, then tilt backwards.

A problem with using the light sensor as primary and only input device is that light emitted from surfaces differs a lot. On a table the light can differ from one end to another depending on the shadows and where the light source is placed. This is a problem since we measure a starting value which we use to correct the movement of the robot all the time. If the light emitted from the surface changes a lot, we can not use the start value across the table.


Status
We completed the exercises as best we could. Our robot was build according to the images (*1), but we used bigger wheels, thinking that would make it better at balancing. This however made it a little harder to make small corrections.
We had the robot balance only a few seconds before toppling over. The light sensor was too sensitive to shadows from different objects. And our constants may not have been tuned correctly, but it was a lot harder than making corrections to have the robot follow a line.
We should have used an accelerometer instead.


References:
(*1) http://www.philohome.com/nxtway/nxtway.htm
(*2) http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html

No comments:

Post a Comment