Wall Following

The goal of this part of the lab was to create code to make the robot (and the simulated robot) follow a wall.  The first part of our approach to this problem was to design an algorithm for making the robot follow walls.  The basic algorithm our design uses is as below:

1.  Find the closest wall
2.  Move to a desired distance from the wall
3.  Turn and start moving along the wall, staying the desired distance away
4a.  Avoid running into a wall ahead of you
4b. Turn into gaps to your right

The final design follows this simple plan.  It implements PID control to first get within the desired distance of the wall and then stay at the desired distance from the wall.  The error used in the PID equation is computed by finding the shortest distance from any of the infrared sensors and using that value minus the desired distance. 

When the robot detects nothing on its right side, it curves to the right to follow corners.  When it detects something in front of it, it starts to turn, increasing the turning velocity and decreasing the forward velocity the closer it gets.  Currently,
it does not back away from the wall if it bumps it due to a version control problem.

Before we were able to test the program on the Nomad 200, we used the two maps given for the simulator Assignment A (shown below).


Figure 2. Wallfollowing Map 1.


Figure 3. Wallfollowing Map 2.

Solution:
The final code that implements both wall following and the bug algorithms can be found here: Wallfollowing Code.

Results of wall following simulation:

The robot worked pretty well in the maps.  Instead of implementing left following code, I wrote code to follow walls right.  The main problem is that the robot sometimes runs into the very corner of the wall.  Changing the distance away from the wall it travels will fix this, but the ideal distance has to be experimentally determined for each map.  The value of 8, or a little over half the IR range, yeild fair results for all of them.  A simple back off algorithm would probably keep the encoders from getting as far off sync when the corner is hit.  The other problem is that the robot can get lost if it moves too far from any wall.  This could be fixed by having it rely on its sonar if all of its IR sensors detect nothing.   However, this was not implemented because by the time this happens the robots wall following code has already failed in its task.  Once the program was finished it only happened due to simulator artifacts (see below).

The major problem we uncovered actually is in the simulator itself.  When running the Xsession across a slow network connection, the simulator starts introducing control delays.  Sometimes these can be seen as gaps in the traces.  More seriously, this can cause the PD control to oscillate wildly.  This means that the control will probably have to be retuned when the algorithm is used on the actual Nomad.

The traces of the robot can be seen below. 


Figure 4. Simulation of Wallfollowing Code in Map 1.
 


Figure 5. Simulation of Wallfollowing Code in Map 2.


Back