Home > AreaBot, My Robots, RobotC Code > AreaRover III – Another wall following behavior

AreaRover III – Another wall following behavior


While I was experimenting with the Lego Ultrasonic (US) sensor for following a wall, I thought I would create a behavior for following a wall using only the front bumper.  This serves two purposes.

  1. As a backup or augmentation to the US wall following.
  2. As an alternative to the US wall following where only the front bumper is needed to accomplish similar goals.

Download the code: bbAreaRover3.zip


When the robot bumps into an object, give it the opportunity to follow along its edge using the bumper as a guide.  Its goal is the same as following a wall with the Ultrasonic sensor, but it accomplishes its goal using a bumper.

When trying to cover as much area as possible in an odd shaped room or multiple with chambers with a small opening, just bouncing off the walls will work, but the robot may not get into the next chamber as often.  Doorways and obstacles tend to force the robot to stay in the current chamber.  Following a wall through the doorway greatly improves the chances that the robot will enter other chambers to search that area.

To follow a wall with a bumper sensor, the robot only know two things about its world.

  1. I hit an object
  2. I am not hitting an object

The robot does not know that an object is near, or how far away it might be.  With this in mind, the robot needs to bump into something, turn away, and arc toward it again (and repeat).  It is not pretty, but it is effective in following a wall.


Our robot needs to follow a pattern of action that keeps it near a wall, and allows it to follow along using only the front bumpers.  To achieve this goal, the robot needs to do the following.

  • On collision –
  • Spin away from the wall until the bumper is no longer pressed
  • Arc back toward the wall until it collides again


This process turns out to be fairly easy to implement.  The behavior BUMP WALL FOLLOW was modeled as a finite state bWallFollowStateDiamachine in order to allow a sequence of events to occur in order to provide the best opportunity to follow an object.

The behavior starts in START state and waits for a trigger condition to occur.  The trigger condition is a collision from the front bumper.  In my case, I also added a bit of random chance to the behavior to allow other behaviors to react during a collision sometimes.  At this point, the state becomes WALL FOUND and the robot starts to spin away from the the obstacle.  It spins until the bumper is no longer activate plus some time to get it into the next position.  The state change to LOST WALL and the robot starts to arc forward in an attempt to find the wall again.  Three conditions can occur from this state.

  1. The robot does not find the wall during a set time limit.  Maybe it was in a doorway and went around a corner.  Maybe the object moved out of the way.  There is no reason to search forever.  The state resets to START.
  2. The robot becomes bored and stops following the wall.  There is a global time set for each time the robot starts to follow a wall that expires.  This keeps the robot from latching onto a wall and following it indefinitely.  The state resets to START.
  3. The robot finds the wall by colliding with it again.  This is the desired condition to continue following the wall.    The state resets to FOUND WALL, and the process repeats.


Wall following can take on many forms that are all effective.  Using the bumpers looks awkward, but is very easy to program and functions accurately and consistently.

  • I only needed one bumper (that covers the front of the robot) to implement wall following.
  • This method was very consistent and effective.
  • The robot looked crazy when following the wall and was a little destructive.
  • The robot easily found a small doorway into the second chamber of the room.
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: