... | ... | @@ -49,21 +49,24 @@ It always takes 35 ms to call getDistance. If you make the program sleep for 30+ |
|
|
This shows us that the NXT continually fetches data each 30 ms, even while the program sleeps, and getting the data have a delay of 5 ms. Because of this the optimum amount of sleep before is subsequent getDistance call is 30 ms.
|
|
|
|
|
|
### Exercise 3
|
|
|
It is possible to measure a distance of 254 cm when placing the NXT on the floor 254 cm away from a large wooden box with a smooth uniform surface.
|
|
|
It is possible to measure a distance of 254 cm when placing the NXT on the floor 254 cm away from a large wooden box with a smooth uniform surface. It also requires a surface which is orthogonal with the sensor.
|
|
|
|
|
|
We tried on another surface (light grey) but there were no problems.
|
|
|
|
|
|
It requires a surface which is orthogonal with the sensor.
|
|
|
![254 measurements](http://i.imgur.com/oaYtwFm.jpg)
|
|
|
> Here we managed to measure a distance of 254 cm.
|
|
|
|
|
|
On an upwards angled wall the NXT could not measure beyond 101 cm and using a large plant container the limit was 175 cm.
|
|
|
|
|
|
Using the speed of sound (340,29 m/s) and the max distance of 255 cm we can calculate the time limit of the sensor:
|
|
|
![Angled wall measurement](http://i.imgur.com/pRkejJE.jpg)
|
|
|
> At this angled wall we could only measure up to 101 cm.
|
|
|
|
|
|
![Plant measurement](http://i.imgur.com/RCVsh5C.jpg)
|
|
|
> At this plant we could measure up to 175 cm.
|
|
|
|
|
|
2,55 m * 2 / 340,29 m/s = 0,015 ms
|
|
|
Using the speed of sound (340,29 m/s) and the max distance of 255 cm we can calculate the time limit of the sensor:
|
|
|
|
|
|
This is half of the delay leJOS has built into the getDistance function.
|
|
|
$2,55 m * 2 / 340,29 m/s = 0,015 ms$
|
|
|
|
|
|
Does this limit the usage of the sensor???
|
|
|
This is half of the delay leJOS has built into the getDistance function. This time limit can most likely limit the usage of the sensor as you will never be able to measure beyond 255 cm even if the sensor could measure the sound coming back from the speaker. In some good conditions we could actually measure 254 cm which means we probably would be able to measure beyond 255 cm in the right conditions.
|
|
|
|
|
|
### Exercise 4
|
|
|
The behaviour of the car is defined like this:
|
... | ... | @@ -72,7 +75,6 @@ The car will continually check for object within range of the sensor (255 cm). I |
|
|
The Tracker uses a PID controller in the control loop. Such a controller is defined by calculating an error value as the difference of a setpoint and a measured process variable. It then uses a manipulated variable to reduce the error.
|
|
|
The setpoint is the desired value of 35 cm stored in desiredDistance. The process variable is the measured distance to the object stored in distance. Finally the manipulated variable is stored as power as two times the error capped at maxPower.
|
|
|
|
|
|
|
|
|
### Exercise 5
|
|
|
For this exercise we have experimented with the TrackerController program to adjust the values of minPower and Gain. The variable minPower holds the minimum power of the motors where 0 is no power and 100 is maximum power. Setting this to 100 will force the car to always run at top speed making it sprint backwards and forwards to stay at the desired distance. The other variable called Gain is multiplied with the calculated error to get the needed correction. If this variable is set to 10 or more the car will again oscillate at top speed.
|
|
|
|
... | ... | @@ -122,7 +124,7 @@ while ( running ) { |
|
|
Car.controlRight(powerRight, motorRight);
|
|
|
|
|
|
//Delay.msDelay(sampleInterval);
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
The rest of the code can be found [here](https://gitlab.au.dk/lego-group-8/lego/tree/master/lesson2/WallFollower)[5].
|
|
|
|
... | ... | @@ -137,8 +139,14 @@ Inspired from a program by Philippe Hurbain[3]. We implemented our own WallFollo |
|
|
|
|
|
## References
|
|
|
[1] [Exercise material](http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson2.dir/Lesson.html)
|
|
|
|
|
|
[2] [Figure - Inkpatron](http://i.imgur.com/sAR8ELR.jpg)
|
|
|
|
|
|
[3] [TrackerController video demonstration](https://vimeo.com/120279261)
|
|
|
|
|
|
[4] [Philippe Hurbain, WallFollower](http://www.philohome.com/wallfollower/wallfollower.htm)
|
|
|
|
|
|
[5] [Wall follower video demostration](http://1drv.ms/1Goiheq)
|
|
|
|
|
|
[6] [Wall follower code](https://gitlab.au.dk/lego-group-8/lego/tree/master/lesson2/WallFollower)
|
|
|
|