Thursday, 21 June 2012

Legolab 14

Legolab 14
Date: 07-06-12
Duration: 7½ hours
Group members attending: Tore, Troels & Kristian

Goal
Write a program for the robot that will allow it to follow the point-chain arrays created last time.
Find a solution to the live link between the computer program and the robots program.

Plan   
1. Get the robot to drive along the point lines created last time: Have the robot drive to the starting point, get it to follow/draw the line and at the end, the robot should return to the starting position and heading. Then do the same for the next line.
2. Create a bluetooth connection to the nxt. Be able to write between the NXT and the PC.
3. Small changes to the robot.

Execution
1.
We have the algorithm to convert images. This program will be run on the computer, so we need the counterpart for the NXT. We modified a previous program, that implemented the navigation class “DifferentialPilot”. The run method now takes the 2d array of point chains and move through the chain step by step. For each step we calculate the angle to turn to as well as the distance to travel. When the different human calculation errors was corrected, it seemed to work, mostly this was errors in calculating the correct angle, that is, the angle between the current heading of the robot and the next heading.
Another problem was that the white board was too smooth. The wheels did not have a good  enough grip and so they would spin in place. To fix this we changed the speed and the acceleration of the robot, by using the build-in setAcceleration() and setTravelSpeed() in the DifferentialPilot.
The line drawn looked as expected, but we had a lot of trouble getting the robot to return back to the origin. After a long testsession, the conclusion is that we either have a wrong diameter between the wheels, or the program did not make the robot turn the correct amount of degrees. This will be tested next labsession, and hopefully corrected.

2.
We created a bluetooth connection between the robot and the PC(*1). We need this to transfer our point chains and make the robot follow these lines. Right now we are mostly using it for debugging purposes. We write out states from the robot so it is easier to track bugs.

We had a little trouble with the bluetooth connection since the documentation of leJOS are not the best in the world. We got some strange exceptions but eventually figured it out. We had some problems with writing strings from the NXT to the computer, because we were only able to transfer a single char at a time. We ended up writing this as a char array. Then we decoded the string array using “%”-sign as a line separator(*2). This was done because the library cannot figure out when line endings occur.

The code is rather simple. The robots starts out by waiting for an inbound connection. When this connection is established the robot will start driving. While the robot is driving it will send strings to the computer.

3.  Last time, the robot looked like this:
It seemed like the right idea, but then we forgot to put a cable in the motor, and the motor was too close to the wheels. We turned the motor 90 degrees, and changed the lifting mechanism to use gears and a sort of wire. This is shown here:
The pen is still slightly loose, but the lifting mechanism has been improved.


Status
The great success of today was getting a bluetooth connection established. This has made it a lot easier to debug. We are now able to get values printed to the computer.
The first version of the program to get the robot to draw is almost finished. The big problem today was either a too small diameter between the wheels or the DifferentialPilot class is imprecise. This will be tested and hopefully corrected next time.

References
(*1) http://troelskristiantore.blogspot.dk/2012/05/legolab-code.html
(*2) http://troelskristiantore.blogspot.dk/2012/05/legolab-code-drive.html

No comments:

Post a Comment