Date: 11-06-12
Duration: 4 hours
Group members attending: Tore, Troels & Kristian
Goal
Cut out wooden walls. Begin implementing the recalibration phase. Fix minor bugs in the existing code.
Plan
1. We need to cut out two wooden walls. These will be placed along the x- and y-axis on the whiteboard and will be used to recalibrate the robot and return it to the starting position.
2. Implement the calibration algorithm described in the last lab session and test out how well it works.
3. Make minor changes to the drawing algorithm, we cannot draw closed circles.
Execution
1. We could not find any of the wood we were shown at an earlier lab session. For today’s testing purposes, we turned over two tables and used them as walls:
We used some lego wheels to lift the tables a little. This was done to make sure that the tables created a 90 degrees angle with the floor and with each other.
2. We changed the algorithm a bit and used two ultrasonic sensors instead. They are mounted as seen below:
Then the calibration phase was actually rather simple. We still have two steps: pre- and recalibration.
Precalibration:
The robot is placed on the whiteboard. This position is now (0,0) and it is headed along the x-axis.
It turns -90 degrees, measures the distance to the wall on the x-axis, turns another -90 degrees, measures the distance to the wall on the y-axis, and then turns -180 degrees to face the original heading. These two values give the place of origin compared to the walls.
Recalibration:
This happens after the robot has drawn a line and has returned back to the origin. The robot will almost always be off by a few centimeters. It is programmed to be facing the original direction along the x-axis after the return. The recalibration goes as follows:
The robot turns -90 degrees and faces the wall on the x-axis. With the two ultrasonic sensors we get two values. If the robot is perpendicular to the x-axis, the two values are equal. If the values are not equal, the robot turns a little and take new measurements to get two new values. This is repeated until the two values are equal. Depending on which of the values is greatest we turn either clock- or counter clockwise.
The robot then drives the difference between the original value from the precalibration phase and the new measured value. The robot is now reset with regard to the x-axis. It then turns -90 degrees, and does this again with the y-axis and finally turns -180 degrees. It is now back in the original position.
Here is a video, between each line drawn the recalibration can be seen (*1).
And a picture of the result:
The five dots at the bottom right is the position of the tusch after each recalibration. The distance between the upper and lower dot is ~4 cm. This margin of error, we think, is permissible for our purpose. The real gain of the recalibration is, that the robot aligns pretty well with the x-axis after each line.
The code can be seen in the Drive class (*2).
3.
Our previous drawing algorithm had a problem when drawing circles, since the starting pixel of the circle should be connected to the endpoint pixel. This didn’t happen since the starting pixel gets set to zero when the robot starts and so it wouldn’t be seen as a neighbour to the endpoint pixel. We changed the algorithm so it saves the starting point. We then use this to check if the starting pixel and end pixel are neighbours, and if so, draw the last line to close the circle.
Status
We completed the calibration-part. It seems to work rather well, although we need to test it a little further.
We made slight changes to the point chain program, we are now able to draw circles. In the previous version, there would be a small gap from where the robot ends the line and the start of the line.
References
(*1) http://youtu.be/h-GW8L1HLqo
(*2) http://troelskristiantore.blogspot.dk/2012/05/legolab-code-drive.html
No comments:
Post a Comment