Date:
28/4-2014 (round 1), 29/4-2014 (round 2)
Duration of activity:
10:00 - 15:00 (round 1), 11:30 - 14:00 (round 2)
Group members participating:
Levi, Christina, Benjamin
Goal:
In this lab session we will apply the tacho counter of the NXT motor to keep track of the position and direction af a LEGO car with so called differential drive where two motors are used independtly to move and steer a car as shown in Figure 1. 
| 
Figure 1 A car with differential drive that can turn in place [1]. | 
Navigation
We started out with building the basic car, as described in the Mindstorms education manual.
Instead of mounting the thick wheels used in the manual, we used the smaller and thinner solid rubber wheels, so to easier measure radius and circumference of the wheels.
The diameter of the wheels is 4.3 cm and isn’t affected much when the NXT is placed on the car, and the wheels have to support it (thereby possibly being pushed down making them more flat). The track width is measured from the center of the right tire to the center of the left tire, as the documentation describes is should be. This distance is 9.6 cm.
A whiteboard marker was attached to the front of the car. A construction was made so that the marker is pushed towards the board only by gravity, and in a slightly tilted way so that the marker is tilting towards the car. This is important because the car experiences too much resistance from the marker touching the board, if the marker is fixed in a way that ‘pushes’ it to hard against the board.
When using the above measurements for wheel diameter and track width, we got the following pattern drawn on the white board. On the pattern we have marked the starting and ending point with a red marker, as well as drawing lines between the points that the car wants to reach.
The car was supposed to make a turn that would intersect with the first line in a right angle (see picture below), but from the picture it is clear that this is not the case.
We therefore tried adjusting the measurements of the wheels’ diameter to something smaller, because the car doesn’t turn as much as it should, and that we therefore think that the car will turn some more if it ‘thinks’ it has smaller wheels. We changed the diameter to 4.3 cm and got the following result:
We could see that this helped in the degree of rotation and then changed the diameter to 4.1 cm, and got the following result:
We think that we achieve the degree of the rotation of the car to produce a right angle at the intersection as it should, using close to 4.1 cm as the diameter of the wheels.
Experimenting some more with the car’s ability to rotate the correct amount (as Bagnell[2] notes is it’s weakness) along with it’s ability to drive forward the correct distance, we made it go around in a square, that is: going from (0,0) to (20,0) to (20,20) to (0,20) to (0,0).
With the values as the following: diameter = 4.1 cm, track width = 9.7cm, the result was as follows:
We tried experimenting with different values for the diameter and track width (noted on the board for the different produced drawings of the route), and some of them can be seen here:
We tried changing the wheels to some one that we thought might have a more easily accurately measurable contact surface.
We then got a hint that we could try calibrating the values by driving the car forward and then rotate it 180 degrees, and set the values so that the point where it ended was exactly on the line that it had driven forward on. We experimented with this and found values (using the new wheels) of 5.61 cm for the wheelDiameter and 10.5 cm for the track width, to produce a correct result. A picture of the result when calibrated is shown below:
We then tried to perform a rotation in between the goTo-methods when attempting to draw a square, using the rotateTo-method, because we now were able to turn the car the exact correct amount (at least when turning 180 degrees).
The code for this approach is shown below:
This approach helped a lot, and we were able to produce an (almost) exact square.
The video below shows the robot producing the square.
The picture below not only shows the drawn square by the car, but the coordinates and coordinate system that the car ‘produces’. It also shows how the system interprets arguments for the value of degrees; the angles. We experimented with different ways of rotating the car (like for instance writing -270 instead of 90) and found that the drawn system is how it works.
It is important to notice that the drawing produced is not a representation of the center of the car (center = the center between the wheels), and that the produced drawing therefore is displaced from the actual coordinates of the car. See drawing below.
However, the displacement is relatively the same, so the produced drawing can be used as a ‘displaced coordinate representation’ relatively, to conclude whether or not the car actually turns the correct amount and drives the correct amount forward before turning (because if the center between the wheels moves 10 cm forward, so does the marker placed in front of the car, and if the car turns 90 degrees, so does the marker).
After this worked, we again tried getting the car to work producing a square using only goTo-methods and not the rotateTo-methods in between. Other values were used (5.55 cm for the wheel diameter and 10.62 cm for the track width found by experimenting), and a square was finally produced.
The picture below shows the square produced.
Navigation while avoiding objects
Our approach to make the car move from place to place using the leJOS navigation system while avoiding objects in front ot it, is to attach an ultrasonic sensor to the front of the car, and sense if anything comes within approximately 30 cm of the front of the car.
If it does, we want the car to make a turn in a certain direction and go a bit forward, before beginning to go to the end point again. If something new gets in the way, the car should avoid it in the same manner and continue to try to get to the end point afterwards.
The code for this approach can be seen below, and be found here [3].
Making the car go forward is done by adding 20 to the value of the Y-coordinate, doing nothing to the X-coordinate and then making the car go to this new coordinate set:
robot.goTo(pose.getX(), pose.getY()+20);
We found that it was necessary to clear the path for the Navigator class robot for it to properly go to the new point before attempting to go to the endPoint.
A video that shows the car avoiding objects and getting to its destination is here:
Improved Navigation
In [2] there is a formula that shows how the position and direction are updated during the moves of a mobile robot. In [5], another update formula is used. What is the difference, what is the most accurate? Try to figure out how leJOS updates the position and direction. Can you use [5] to improve that? Or?
We did not complete this task. Unfortunately, mainly because of lack of time.
Conclusion
We completed the first two tasks to a satisfactory degree. Unfortunately, we ran out of time and were unable to get the last task done.
References
- [1], Java Robotics Tutorials, Enabling Your Robot to Keep Track of its Position. You could also look into Programming Your Robot to Navigate to see how an alternative to the leJOS classes could be implemented.
- [2], Brian Bagnall, Maximum Lego NXTBuilding Robots with Java Brains, Chapter 12, Localization, p.297 - p.298.
- [3], Avoider.java





 
