Line follower algorithm: Difference between revisions

From wikiluntti
No edit summary
Line 1: Line 1:
== Introduction ==  
== Introduction ==  
The easiest line follower algorithm is Zig Zag algorithm, which goes like zig zag and never straight. However, it is funny to observe the movements of the robot, and test the meaning of the different parameters.


=== Aim ===
=== Aim ===
If block (programming). Color.


== Robot ==  
== Robot ==  
Almost any root will do, but this example is done using Asimov 2/ Verne.


=== Sensors ===  
=== Sensors ===  
The color sensor is used to read the color.


== Example  Video ==  
== Example  Video ==  
<youtube>DN2prlLoyPo</youtube>


== Theory ==
== Theory ==
''Zig zag'' algorithm turns to right if sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block. The speed and turning value need to be considered and adjusted.
[[File:Zigzag.png|thumb|''The Zig Zag'' algorithm.]]
== Example Code ==
Zig Zag never drives straight. Either it turns to left or right. However, it can be made very fast, and reliable---of course depending on the line. The turning part is coded into ''if else'' block which is in the loop.
[[File:Zigzag.png|thumb|Zigzag algorithm]]


== Exercises ==
== Exercises ==
* Use the other side of the line to follow the line
* Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line
* Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line.
* Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors.
* Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end.





Revision as of 20:52, 16 October 2020

Introduction

The easiest line follower algorithm is Zig Zag algorithm, which goes like zig zag and never straight. However, it is funny to observe the movements of the robot, and test the meaning of the different parameters.

Aim

If block (programming). Color.

Robot

Almost any root will do, but this example is done using Asimov 2/ Verne.

Sensors

The color sensor is used to read the color.

Example Video

Theory

Zig zag algorithm turns to right if sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block. The speed and turning value need to be considered and adjusted.

The Zig Zag algorithm.

Example Code

Zig Zag never drives straight. Either it turns to left or right. However, it can be made very fast, and reliable---of course depending on the line. The turning part is coded into if else block which is in the loop.

Zigzag algorithm


Exercises

  • Use the other side of the line to follow the line
  • Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line
  • Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line.
  • Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors.
  • Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end.


Back to Mahtavaa Matematiikkaa 2020