Obstacle Avoidance: Advanced

Obstacle Avoidance: Advanced


Project Overview:


The goal for this project are to construct and program a robot that can avoid obstacles. Once the robot detects an object in its way it should do the following

1. Stop moving

2. Scan the area to the left of the robot

3. Scan the area to the right of the robot

4. Turn in the direction with the most clearance

5. Continue moving until new obstacle is detected

Programming the robot

The programming part of this project will be broken into smaller parts.




Object Detection


The first thing we want to do is to stop the robot before it runs into an object.


Pseudo-code:

Drive robot forward

Wait until ultrasonic sensor measures a value less than a certain distance

Stop robot

Looking Around


Once the robot has stopped, we will use the medium motor to rotate the ultrasonic sensor to the right and then to the left.


How many rotations will it take to turn the sensor from the forward position to the right position?

How many rotations will it take to turn the sensor from the right position to the left position?

How many rotations will it take to turn the sensor from the left position to the forward position?


Saving the measurements


After we turn to the left and right we want to take a distance measurement and then store it in a variable so the we can compare the values later on.

Above you can see that after each turn we take a measurement from the sensor and store it in a variable named right or left

Making a decision

Now that we have two values, one from the right side and one from the left side, we can compare the two to make a decision on which direction to turn.


What does the value stored in each variable represent?


What does is mean for left to be greater than right?


If left is greater than right which direction should the robot turn?


If left is not greater than right which direction should the robot turn?

Putting in all together


The final step to to put all the pieces together test, improve and repeat!