0

Line Robot - Basic lessons - Exercises - Wall following with 2 sensors

If we want to follow wall better or do not have enough space to bend front sensors, we can use 2 sensors per side instead of 1.

Theory

Wall is thick line on the right of the picture, robot's ideal position is dashed line (robot's longitudinal axis in the ideal position). Therefore, the robot is too far from the wall and it is rotated to the wall. Red rectangles are distance sensors and red dashed lines are distances.

2 sensors allow us to estimate 2 errors:

  • rotational error and
  • error in distance to the wall.
We must address both issues. Difference between front and rear distances can be used to determine rotational error. Mean value of the both sensors is distance to the wall. In every moment we must calculate both errors and drive the robot in a way that tries to eliminate both of them.

Task: smooth wall following with 2 sensors.

Write a program that implements the theory above, therefore follows a wall with 2 sensors. This task is difficult. If You are not an experienced programmer, just take a look at the solution an try to understand the logic.