... | ... | @@ -75,6 +75,39 @@ minPower = 50, Gain = 2 |
|
|
[![Exercise 5 - Low power and gain](http://img.youtube.com/vi/ymecZEaL5YU/0.jpg)](http://www.youtube.com/watch?v=ymecZEaL5YU)
|
|
|
|
|
|
### Exercise 6
|
|
|
The code produced in this exercise was based on Philippe Hurbain's implementation[1]. The body of the control loop is listed below:
|
|
|
|
|
|
```java
|
|
|
distance = sensor.getDistance();
|
|
|
|
|
|
leftMotor.forward();
|
|
|
rightMotor.forward();
|
|
|
|
|
|
if(distance <= desiredDistance) //close to wall
|
|
|
{
|
|
|
if(distance <= desiredDistance * 0.7) //very close
|
|
|
{
|
|
|
rightMotor.backward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rightMotor.flt(true);
|
|
|
}
|
|
|
}
|
|
|
else //far from wall
|
|
|
{
|
|
|
if(distance >= desiredDistance * 1.1)
|
|
|
{
|
|
|
leftMotor.flt(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Thread.sleep(10);
|
|
|
```
|
|
|
|
|
|
A possible improvement on our implementation could be a proportional control system, with the error being used to control the power of both motors, allowing smoother turns than the `flt` and `backward` functions used in this exercise.
|
|
|
|
|
|
|
|
|
Wall follower:
|
|
|
|
|
|
[![Exercise 6 - Wall Follower](http://img.youtube.com/vi/4jiRYaAJqrE/0.jpg)](http://www.youtube.com/watch?v=4jiRYaAJqrE)
|
... | ... | @@ -85,4 +118,7 @@ Modified/improved Wall Follower: |
|
|
|
|
|
Sharp turn:
|
|
|
|
|
|
[![Exercise 6 - Wall Follower: Sharp turn](http://img.youtube.com/vi/9F_EneaCpnM/0.jpg)](http://www.youtube.com/watch?v=9F_EneaCpnM) |
|
|
\ No newline at end of file |
|
|
[![Exercise 6 - Wall Follower: Sharp turn](http://img.youtube.com/vi/9F_EneaCpnM/0.jpg)](http://www.youtube.com/watch?v=9F_EneaCpnM)
|
|
|
|
|
|
#References
|
|
|
1. Philippe Hurbain, WallFollower - http://www.philohome.com/wallfollower/wallfollower.htm |
|
|
\ No newline at end of file |