... | @@ -105,3 +105,55 @@ https://drive.google.com/open?id=0B4Vn_sxU595gV19PZXQ3VGdGLVU&authuser=0 |
... | @@ -105,3 +105,55 @@ https://drive.google.com/open?id=0B4Vn_sxU595gV19PZXQ3VGdGLVU&authuser=0 |
|
|
|
|
|
minPower: 100 Gain: 1
|
|
minPower: 100 Gain: 1
|
|
In this setting we achieved the goal of making the robot oscillate in an effort to reach the desired distance to the wall. With minPower set to 100 the robot continuously managed to drive past the desired point. Once the destination point was exceeded the robot drove in reverse to get back to its desired destination. Another reason why the robot drives past its intended destination is the sample rate which is set to 100ms. This means that the robot is constantly influenced by a small delay as the sensor interprets the environment. In order to compensate this behaviour the gain value can be manipulated causing the robot to slow down gradually as it approaches the desiredDistance.
|
|
In this setting we achieved the goal of making the robot oscillate in an effort to reach the desired distance to the wall. With minPower set to 100 the robot continuously managed to drive past the desired point. Once the destination point was exceeded the robot drove in reverse to get back to its desired destination. Another reason why the robot drives past its intended destination is the sample rate which is set to 100ms. This means that the robot is constantly influenced by a small delay as the sensor interprets the environment. In order to compensate this behaviour the gain value can be manipulated causing the robot to slow down gradually as it approaches the desiredDistance.
|
|
|
|
|
|
|
|
## Exercise 6
|
|
|
|
|
|
|
|
**Task:**
|
|
|
|
Program the robot to follow a wall based on the distance measured by the ultrasound sensor. This includes navigating around both left and right corners. Compare Philippe Hubains Wall Follower programs control algorithm with the different suggestions on page 179, exercise 5.1.3.
|
|
|
|
|
|
|
|
**Plan:**
|
|
|
|
We intend to base our Java program for following walls on the overall structure of the NQC Wall Follower program. The core of the program is one if sentence containing three possible right turns and two possible left turns depending on the difference when comparing distance readings. We customized the tracker.java program to istead of finding a desired distance and stop, it would find a distance and follow the wall and keep the distance. This was done by changeing the while loop of the tracker.java program. (See fig. 3)
|
|
|
|
|
|
|
|
```
|
|
|
|
while ( running )
|
|
|
|
{
|
|
|
|
distance = us.getDistance();
|
|
|
|
|
|
|
|
value = us.getDistance();
|
|
|
|
|
|
|
|
variation = x - value;
|
|
|
|
x=value;
|
|
|
|
|
|
|
|
//if ( distance != noObject )
|
|
|
|
//{
|
|
|
|
if(x<=50) //close to wall
|
|
|
|
{
|
|
|
|
if(x<=25){
|
|
|
|
Car.forward(80, 0); //very close, turn in place
|
|
|
|
Car.backward(0, 80);
|
|
|
|
}
|
|
|
|
else if(x<=40){
|
|
|
|
Car.forward(80, 70); //Close enough, turn
|
|
|
|
}
|
|
|
|
else if(x<=30){
|
|
|
|
Car.forward(80, 60); //a bit too close, shallow turn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // far from wall
|
|
|
|
{
|
|
|
|
if(x>=75){
|
|
|
|
if(variation < 5){
|
|
|
|
Car.forward(70, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(x>=55){
|
|
|
|
Car.forward(60, 80);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dl.writeSample(distance);
|
|
|
|
|
|
|
|
Delay.msDelay(sampleInterval);
|
|
|
|
}
|
|
|
|
``` |
|
|
|
\ No newline at end of file |