... | ... | @@ -50,7 +50,23 @@ The full code is |
|
|
|
|
|
### Setup
|
|
|
|
|
|
The physical setup for this test is identical to the single behavior test.
|
|
|
The setup is the same as described in the "Setup" section for the exercise "Single behavior - Avoid".
|
|
|
|
|
|
#### Triggerig conditions and behavioir implementation
|
|
|
|
|
|
**Cruise**
|
|
|
|
|
|
The `Cruise` class does not have a trigger condition. The cruise class drives the car forward by applying a power of 70 to both motors.
|
|
|
|
|
|
**Follow**
|
|
|
|
|
|
The trigger condition of the `Follow` class is that the `frontLight` is greater than the `lightThreshold`. The threshold value is set in the constructor, and is therefore the light value when the program is started. If the light value never reaches a value higher than the first, the Follow class will never issue a command to the car.
|
|
|
|
|
|
If the condition is met, the light to the left and right sides of the car is measured, and the course adjusted by a delta expression which equals the difference in the two light values. Thereby the car will make sharper turns towards the light with increasing light intensity.
|
|
|
|
|
|
**Avoid**
|
|
|
|
|
|
The trigger condition for the `Avoid` class is that the `frontDistance`, which is measured continuously, becomes less than the `stopThreshold` which is set to 30. If the trigger condition is met, the car will stop, turn left and measure distance, turn right and measure distance and finally proceed in the direction with the largest distance. Even though the implementation does not consider the scenario where both the `leftDistance` and `rightDistance` equal 255, like in the case of the single narrow obstacle, since the car does not return from having measured the distance to the right, it will process in the right direction.
|
|
|
|
|
|
### Results
|
|
|
|
... | ... | @@ -61,7 +77,7 @@ The physical setup for this test is identical to the single behavior test. |
|
|
|
|
|
### Results
|
|
|
|
|
|
## Ligth turning motor
|
|
|
## Light turning motor
|
|
|
|
|
|
### Setup
|
|
|
|
... | ... | @@ -69,8 +85,9 @@ The physical base setup in this test is identical to previously tests. In order |
|
|
|
|
|
[INSERT IMAGE]
|
|
|
|
|
|
A the class `Follow` is replaced by a new class called `FollowSensorTurn` which make use of the NXT motor abstraction to turn the light sensor. To ensure that the light sensor performs acurate turns the method `rotate()` is used. This method takes a value in degrees as input and then use the tachometer as feedback when turning the motor.
|
|
|
The structure of the code is similar to the Follow class. The light sensor is rotated 45 degrees the left, then to the right and in both cases a light value is acquired. FInially the light sensor is rotated to its initial position (pointing forward) and the power for the two main motors are calculated. The main part of the `FollowSensorTurn` class is shown in the code snippet below.
|
|
|
A the class `Follow` is replaced by a new class called `FollowSensorTurn` which make use of the NXT motor abstraction to turn the light sensor. To ensure that the light sensor performs accurate turns the method `rotate()` is used. This method takes a value in degrees as input and then uses the tachometer as feedback when turning the motor.
|
|
|
The structure of the code is similar to the Follow class. The light sensor is rotated 45 degrees the left, then to the right and in both cases a light value is acquired. Finally the light sensor is rotated to its initial position (pointing forward) and the powers for the two main motors are calculated. The main part of the `FollowSensorTurn` class is shown in the code snippet below.
|
|
|
|
|
|
|
|
|
```java
|
|
|
// Get the light to the left
|
... | ... | @@ -94,7 +111,7 @@ frontLight = light.getLightValue(); |
|
|
|
|
|
### Results
|
|
|
|
|
|
The result is seen
|
|
|
The result of this test is seen in the video "Concurrent behavior - Light turning motor". By starting the car in a somewhat dark area the lightThreshold becomes low and then when the car leaves the dark area it will enter the while loop where the turning of the light sensor is performed. After the car is initialized and is out in the light area we are able to "pull" the car either left or right by holding a flash light close to the car.
|
|
|
|
|
|
## SharedCar and Arbiter
|
|
|
|
... | ... | @@ -123,6 +140,7 @@ In Fred Martins code, arrays are preallocated to be able to contain ten processe |
|
|
|
|
|
[Single behavior] - http://youtu.be/iFmBLXIuRiE
|
|
|
[Single behavior modified] - http://youtu.be/Xvs0y3kdMeA
|
|
|
[Concurrent behaviors] - http://youtu.be/Q02iTiezgPk
|
|
|
|
|
|
[Concurrent behavior - Light turning motor] - http://youtu.be/SRYQU0VrlH0
|
|
|
|
... | ... | |