... | ... | @@ -92,4 +92,21 @@ The takeControl() method in the class DriveForward, has no triggering conditions |
|
|
##### Fig. 5: takeControl() method from DriveForward class always returns value 10.
|
|
|
>
|
|
|
|
|
|
In the DetectWall class a value of either 50 or 100 is returned (see fig. 6 below). The returned value is determined by either the sensors or the boolean value ‘active’. If the touch sensor is pressed or the distance measured by the ultrasonic sensor is less than 25 a wall is detected and the method returns a high priority. ‘Active’ is set to true once the action() method is called. This means that the behavior is already active and thus a priority of 50 is returned. However both values from the DetectWall class are both greater than the value from DriveForward, this means that the DetectWall behavior will always suppress the behavior from DriveForward.
|
|
|
>
|
|
|
|
|
|
```
|
|
|
public int takeControl()
|
|
|
{
|
|
|
if (touch.isPressed() || distance < 25)
|
|
|
return 100;
|
|
|
if ( active )
|
|
|
return 50;
|
|
|
return 0;
|
|
|
}
|
|
|
```
|
|
|
##### Fig. 6: the takeControl() method from DetectWall class. Dependant on sensor readings or the boolean value ‘active’ the behavior is prioritised differently.
|
|
|
>
|
|
|
|
|
|
#### Initial research conclusion
|
|
|
From these initial experiments we gained experience and knowledge from implementing different behaviors and prioritise them accordingly. Through the exercise we have an idea of how the Sumo Wrestler Robot can be implemented using the same code architecture. |
|
|
\ No newline at end of file |