2

This wall following algorithm uses the ultrasonic sensor. It has a horrible worst case behavior. Place the robot about 3 cm too far from the wall. Instead of moving closer to the wall, the robot turns toward the wall and spins.

Place the robot too close to the wall and it works very well.

The sensor points out from the right side of the robot, in front of the powered wheels.

Robot viewed from the back. The sensor is on an beam. Making the beam longer did not fix the problem.

Wall Following algorithm using the ultrasonic sensor

How should the algorithm be changed to handle the "too far away" case?

1

If a significant distance from the wall, you'll need to turn 90 degrees in place clockwise, drive up to the wall and turn 90 degrees in place counterclockwise. I'd suggest mounting a touch sensor in front of the vehicle handle the part of driving up to the wall, if that is not possible, estimate from the scanned distance how far the vehicle should drive.

If close to the wall but not close enough to have the wall-following algorithm work correctly, I'd suggest "wiggling": Repeat the following steps until close enough to the wall:

  • rotate left wheel forward by a small angle while blocking the right wheel.
  • rotate right wheel forward by a small angle while blocking the left wheel.
  • rotate left wheel backward by a small angle while blocking the right wheel.
  • rotate right wheel backward by a small angle while blocking the left wheel.

In each step use the same angle (determine an optimal angle by trial and error)

  • Also could set the target distance to +2 cm for a short time, then +1 cm, and then the actual target distance. I was hoping that I had missed a trick in using the ultrasonic sensor. – dfrevert Feb 23 '18 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.