... | ... | @@ -23,7 +23,7 @@ The plan for the day is to build upon previous results [1]. It seemed plausible |
|
|
|
|
|
In a previous lesson we used a single light sensor to make the car be able to follow the edge of a black line. This is the starting point for this task. The light sensor is mounted in front of the car pointing downwards as seen in the following image.
|
|
|
|
|
|
![Lego car a single light sensors attached](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LightSensorSingle.JPG)
|
|
|
![Lego car with a single light sensors attached.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LightSensorSingle.JPG)
|
|
|
|
|
|
The flood light is turned on according to results from a previous lesson [2]. A test program is made where the steering is controlled by a PID regulator. This program is based on experience gained from exercise 4 [3]. The set point was defined as the middle value between the light sensor reading of white and black. In addition to this we implemented a direct PC connection in order to tune the parameters of the PID regulator.
|
|
|
|
... | ... | @@ -38,7 +38,7 @@ By inspecting the LEGO cars line following behavior we quickly realized that one |
|
|
|
|
|
Two light sensors are placed in the front of the LEGO car pointing downwards. Again the flood light is turned on in both sensors. The setup is shown in the following figure.
|
|
|
|
|
|
![Lego car two light sensors attached](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LightSensorDouble.jpg)
|
|
|
![Lego car with two light sensors attached.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LightSensorDouble.jpg)
|
|
|
|
|
|
### Results
|
|
|
|
... | ... | @@ -67,17 +67,17 @@ The `Arbiter` class then passes a `Car` object to each behavior when they are se |
|
|
|
|
|
The two behaviors are implemented as shown in the following diagram.
|
|
|
|
|
|
![Behavioral control](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/BehavioralControl.jpg)
|
|
|
![Behavioral control overview.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/BehavioralControl.jpg)
|
|
|
|
|
|
The `Arbiter` contains a list of the behaviors and constantly check, in a prioritized manner, if the behavior has available commands. This will ensure that the behavior with the highest priority will control the LEGO car, if it has any commands for it.
|
|
|
|
|
|
An overview of the track and where each behavior is activated is shown in the following figure.
|
|
|
|
|
|
![Overview of where on the track each behavior in the program is activated](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/Plan.jpg)
|
|
|
![Overview of where on the track each behavior in the program is activated.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/Plan.jpg)
|
|
|
|
|
|
The PlateauPilot has the highest priority and is implemented as a Finite State Machine (FSM) which is shown in the following diagram.
|
|
|
|
|
|
![Lego car with the gyro sensor placed higher](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/StateDiagram.jpg)
|
|
|
![State diagram for the Plateau Pilot.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/StateDiagram.jpg)
|
|
|
|
|
|
The implementation of this is shown in the following code snippet.
|
|
|
|
... | ... | @@ -118,7 +118,7 @@ The FSM is responsible for performing all turns on the track using an instance o |
|
|
|
|
|
With the current setup the car is able to follow the black line on the first inclined path. However a problem arises in the plateau detection which is illustrated in the following figure.
|
|
|
|
|
|
![Problem with correct plateau detection.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LowGyroProblem.jpg)
|
|
|
![Illustration of the car track, with problem with correct plateau detection.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LowGyroProblem.jpg)
|
|
|
|
|
|
A gyroscope threshold determines whether the PlateauPilot behavior is activated. With the threshold too high the plateau is detected to late (Problem 1) and the LEGO car continues out of the track. With the threshold too low the plateau is detected too early and the LEGO car makes a right turn too soon (Problem 2). It seems to be an impossible task to determine this threshold in the current setting.
|
|
|
This indicates that the problem is related to the gyroscope which might not receive enough impact of the incline change when mounted close to the LEGO car in order to determine a sufficient threshold.
|
... | ... | |