Follow the instructions given on the official website (http://lejos.org/ev3.php).
Once you have all steps done, continue with the next section.
Using the EV3 brick menu, go to:
programs -> MainClass.java -> execute program.
(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.
-
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.
-
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 root@10.42.0.223
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 root@10.42.0.223:/home/lejos/programs/file_name.txt /home/username/local/directory
(Some examples of these files are available here).
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).
The project has the following technical documentation
http://www.lejos.org/ev3/docs/
https://docs.oracle.com/javase/7/docs/
https://docs.oracle.com/javase/8/docs/
-
(Because the version of the JRE (Java Runtime Environment) installed in the memory card is: Oracle Java SE Embedded version 7 Update 60)).
-
The official website to download it:
Java for LEGO® Mindstorms® EV3 : https://www.oracle.com/java/technologies/javaseemeddedev3-downloads.html.
© Djamel ALI, Université de Paris
Licensed under the MIT License.