In order to find its way in the maze, the robot is going to follow the walls. To do so three distance sensors are available. They are measuring the distance on the left, the right and in front of the robot. The problem is tackled by fulfilling two tasks. Driving straight and turning when necessary. Note that the aim is to keep the robot in the middle of the corridor since this is where the object that has to be gripped will be placed.

The overall driving strategy is as follows:

  • When the front sensor measures no obstacle the robot tries to drive straight by keeping the left and right distances to the wall equal.

  • When the front sensor detects an obstacle the robot is more likely to encounter a corner. The distances on the left and right are also measured in order to make the robot rotate in the direction of the free corridor. Same goes for turning right.

Driving straight

As two identical servo motors are used for driving, one could think that by programming the same speed on the two motors using the Servo library of Arduino, assuming the scale of myServo.write() and its origin are kept intact, it is possible to make them run at the same speed. Unfortunately, this is not the case. The origin, i.e. the value between 0 and 180 (usually around 90) for which the motors are still, is different for both. These values are measured and kept for calibration. Moreover, the scale for increasing and decreasing speed is also modified, this complicates the operation of driving in a straight line considerably.

An effective way to tackle this problem is by feedback control. A simple P-controller is implemented where both wheels have different gains. The gains are determined by trial and error. The diagram below summarizes the strategy for driving the robot.