# How do robots move parallel to a wall/line?

I have been studying robotics by myself, lately.

I noticed that there are various mapping, localization methods (popularly under SLAM), but are there concepts relating to the robot moving in a straight trajectory, like strictly parallel to a wall or a line ?

### Common Scenario:

The robots (especially the differential tank drive robots) find it difficult to strictly follow a particular line and displacing itself to a point parallel to its location.

What are the methods used previously and today ?

• I don't know what does "differential drive" mean. So I googled and found the following Q&A: (1) "Understanding differential drive - robotics.stackexchange 2017dec28: robotics.stackexchange.com/questions/14873/…. – tlfong01 Sep 29 '20 at 5:38
• I guess for a differential drive robot, if one motor/wheel drive rotate clockwise, and the other counterclockwise, then the robot will move in a straight. This is open loop drive. Io do closed loop control, I think we can use different sensors, including the following: (1) GPS, can be as precise as 10cm, (2) Magnetometer, (3) IMU (Inertial Measurement Unit (Gyro and Accelero meter integrated). – tlfong01 Sep 29 '20 at 5:45
• Nowadays, even toy digital servos/motors can rotate very precisely, to 12 bit, 2048 steps per revolution. So even without any sensor guidance, can "blindly" move in a "more or less" straight line, to a specified distance. – tlfong01 Sep 29 '20 at 5:49
• Of course you can also use algorithmic (eg, OpenGL) or non algorithmic (eg neural/deep learning/tensorflow etc) techniques, doing visual (LIDAR), object/pattern recognition techniques to help a robot moving in a straight line, or to locate an object. – tlfong01 Sep 29 '20 at 5:56
• Yet one more method, but only you have a wall, not a line. If the wall can reflect ultrasonic waves, then you can use a cheapy ultrasonic sensor for the robot to keep the distance, say 10 cm from the wall, when moving froward. Cheapy ultrasonic sensor can have an accuracy of 1cm or so. IR sensor can do a bigger distance, say one to two meters from the wall, with a lower accuracy, around 5 cm. – tlfong01 Sep 29 '20 at 8:07

The simplest method line following robots use is 3 sensor system: Consider the 2 block sensors, let's assume they sense color. The middle one senses white, the remaining two senses grey. This robot follows the white line in the image.

    X
XXXXX
XXXXX
XX          XXXXX
XXXXXX         XX
XXX        XX
XXX       X
X       X
X      XX
X       XX
X       X
X       X
X       X
^             X       X
|       +---+ X +---+ X +---+
|       |   | X |   | X |   |
|       +---+ X +---+ X +---+
|             X       X
|             X       X
+             X       X
X       X


As the robot advances, towards the turn, the left sensor evetually will sens white color. This is the trigger which makes the robot turn to the left. If the middle sensor senses grey intead of white, the robot knows that it has to turn at a sharper angle. As the left one senses grey again, and the middle one does not sens white, the robot knows that it is off track and has to turn even more sharply to the left. So there are 3 stages of triggers for turning even sharper curves to the left. If you consider the sensors not binary, but being able to sense the "closenes" of the white stripe (as it starts to reflect more light if the sensors on the side approach it) you can derive a signal which is more contous and you can create a PID line following controller based on "how much white does the side sensor sense).

Special logic is required to get back to the track once the robot left the stripe completely. In this case the sensor which last sensed white gives the direction of the line search behaviour. Once the line is found, the line following controller can be re-activated.

This is similar to wall fallowing. In that case distance to a wall gives a similar signal to which a wall following controller (e.g. a PID controller) can be tied to.