Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L LEGO
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • René Søndergaard Nilsson
  • LEGO
  • Wiki
  • Lesson 8 Journal 2

Lesson 8 Journal 2 · Changes

Page history
Plan + two sections authored May 04, 2015 by lildholdt's avatar lildholdt
One light sensor and two light sensor is described
Hide whitespace changes
Inline Side-by-side
Lesson-8-Journal-2.markdown
View page @ 78613968
......@@ -14,46 +14,86 @@ The goal for the day is to make a Lego car follow the Alishan track using a gyro
## Plan
Based on the knowledge gained from [1], a behavioral control will be implemented on the Lego car.
The plan for the day is to build upon previous results [1]. It seemed plausible to use a gyroscope to detect when a plateau is reached however additional sensory needs to be implemented in order for the car to follow the straight inclined paths. The idea is to exploit the black line on these paths and use a light sensor to make the car follow these lines. Behavioral control will be necessary in this setup due to the car having multiple behaviors. It is estimated that hard coding is the optimal solution for the turns do the course of the black line.
## Differential drive
## Implementing a light sensor
### Setup
The original strategy for driving up the ramps proved to be too unreliable.
Two ligth sensors were added to the front of the car to use line following up the the ramp.
In a previous exercise we used a single light sensor to make the car 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. The flood light is turned on according to results from a previous exercise [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 respectively. In addition to this we implemented a direct PC connection in order to tune the parameters of the PID regulator.
### Results
By inspecting the LEGO cars line following behavior we quickly realized that one light sensor is insufficient. The Lego car is only able to follow one edge of the black line. Any deviations from this and the car will perform a 180 degree turn due to the PID implementation. The structure of the track combined with driving up and down requires the LEGO car to be able to approach the black line from both the left and the right side. The solution for this is to implement yet another light sensor.
## Implementing two light sensors
### Setup
Two light sensors are placed in the front of the LEGO car point 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/SetupWithLightSensors.jpg)
The line following was implemented with a PID regulator and using the differential driver for the motors.
The relevant code is shown in the below snippet:
### Results
The line following capabilities is somewhat improved by adding an extra sensor. The LEGO car now follows the center of the black line instead of an edge. However, the PID regulation is slow. When the LEGO car approaches the black line from an angle the PID regulation is not able to correct for this angle and steer the LEGO car onto the black line. In this case the LEGO car just crosses the line. By inspection the cause of this problem is narrowed down to the motor control which seems relatively slow thereby affecting the PID regulation.
In the beginning of the exercise it was estimated that the LeJOS differential pilot would be the optimal solution for motor control due to its use of the tachometer. Since the turning methods of this class takes a value in degrees and a radius as input it seemed as the obvious choice in order to simply the programming of the turns. When using this class, a speed and an acceleration is defined and in order to steer the `steer()` method is called. This method takes an input from -200 to 200 as input and steers the LEGO car accordingly. The problem is that even at an extreme turn rate (200 or -200) the one motor only slows down and never turns in the opposite direction. Therefore sharp turns are excluded when using the differential pilot.
The conclusion is to change from the differential pilot to direct motor control using the leJOS MotorPort class.
## Converting to direct motor control
### Setup
### Results
// TODO: Insert code snippet
## Adding behavioral control
### Setup
### Results
// BESKRIV:
// Skift fra differential pilot class til regulær motor class
// Ikke muligt at udføre effektiv PID regulering grundet motorene ikke kan køre baglæns og er lang tid om falde i hastighed
## Direct Motor Control
## Raising the gyroscope
### Setup
The same physical setup was used on the car.
![Lego car with the gyro sensor placed higher](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LegoCarWithHighGyro.jpg)
### Results
## Switching between PID parameters
### Setup
### Results
## Conclusion
## References
[1] https://gitlab.au.dk/rene2014/lego/wikis/Lesson-8
[2] https://gitlab.au.dk/rene2014/lego/wikis/Lesson-1
[3] https://gitlab.au.dk/rene2014/lego/wikis/Lesson-4
### Video
### Code
......
Clone repository
  • Lesson 1
  • Lesson 2
  • Lesson 3
  • Lesson 4
  • Lesson 5
  • Lesson 6
  • Lesson 7
  • Lesson 8 Journal 2
  • Lesson 8
  • Lesson 9
  • Lesson10
  • Lesson11
  • Home