Difference between revisions of "Line follower algorithm"

From cod3v
 
(No difference)

Latest revision as of 10:49, 25 October 2020


Introduction

The easiest line follower algorithm is the Zig Zag algorithm, which makes the robot move 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 and loop block (programming). Color.

Robot

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

Sensors

The color sensor is used to read the color of line and surroundings.

Example Video

Theory

The Zig zag algorithm turns the robot to right if the sensor 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 and loop block. The speed and turning value need to be considered and adjusted.

The Zig Zag algorithm.

Example Code

The Zig Zag never drives the robot straight. Either the robot turns to the left or to the right. However, the robot 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 that continuously examines the line.

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



Mahtavaa matematiikkaa.png