Skip to content

DjamelALI/line-follower-robot

Repository files navigation

A Line Follower Robot (using leJOS EV3) :


The main steps followed for the realization of this project :

STEP I : Hello World and other basic programs

STEP II : Run Motors

STEP III : Straight line follower

STEP IV : Curved Line follower

STEP V : PID Line follower

STEP VI : Adding 'Find the Line' feature (in 'look_for_line' branch, but not yet finished)

Prerequisites

Follow the instructions given on the official website (http://lejos.org/ev3.php).

Once you have all steps done, continue with the next section.

Getting Started

Using the EV3 brick menu, go to:

programs -> MainClass.java -> execute program.

- Phase 1 : Learning the colors

(by default 4 measures per color to learn, but you can change this in the program MainClass.java by modifying the static variables concerned(NB_OF_COLORS_TO_LEARN)).

As this program is a "frontier"(more precisely "right frontier") follower between the line, and the background, the robot needs to learn in total 4 colors :

  • The color of the line.
  • The color of the background.
  • The color of the border (50% on the line and 50% on the background).
  • The color of Start/Arrival line.

We can also start by making it learn the background color and then the line color, but learning the colors of the "frontier" and the "Start/Finish" line should always be done last and in that order.

- Phase 2 : Start following the line.

  • Now you just have to place the robot on the border (so that the sensor sees 50% of the line and 50% of the background).

  • Click on the 'ENTER' button in the middle so that the robot starts to follow the line.

  • Click on the 'CANCEL' button in the top left corner to stop the robot.

NOTES :

  • If no one clicks on the 'CANCEL' button or the robot does not capture the arrival color, it continues to follow the line, and if at some point it gets lost in the background, it spirals (not yet finished) until it finds the line; and so it never stops by itself (unless it runs out of battery of course ;) ).

  • You can find more information about the circuit used (its different colors like line, background, start/finish in info_field_race.txt and the last captured data before stopping in exit.txt) and the data generated by the robot when following the line (in log.txt) in files located in the directory /home/lejos/programs In the robot's memory (In order to view them directly on the terminal, you can connect to the robot with the command (by replacing the IP address with the appropriate one)):

$ ssh -c aes256-cbc [email protected]

As you can also copy (download) them to your machine by typing the command (by replacing the IP address with the appropriate one):

$ scp -c aes256-cbc [email protected]:/home/lejos/programs/file_name.txt /home/username/local/directory

(Some examples of these files are available here).

Videos

See here videos of a line-follower robot programmed with this code (links to other videos : https://www.youtube.com/watch?v=FhZJFoExKqs , https://www.youtube.com/watch?v=XVTuLtFHmvY).



Documentation

The project has the following technical documentation

http://www.lejos.org/ev3/docs/

Java documentation

https://docs.oracle.com/javase/7/docs/

https://docs.oracle.com/javase/8/docs/



License & copyright

© Djamel ALI, Université de Paris

Licensed under the MIT License.