Avoiding an Obstacle

One of the challenges in Robocup Junior Rescue competitions is to avoid an obstacle that might stop your robot from being able to rescue a “person” from the “swamp”. Often this “obstacle” is a soft drink bottle filled with water, or it may be a lump of rock or a chunk of wood.


Somehow, we have to imagine how to teach our robot to leave the line, go around this obstacle, and find the line again after it has passed the obstacle. We demonstrate this by hand with our LEGO EV3 robot inspired by Julia’s LEGO NXT Robot Ambulance (see her original at the bottom of this web page):

In the video above, you can see that Julia has added a touch sensor to her Robot Ambulance so that her Ambulance will be able to know that it has reached an obstacle. We now need to write code to use our own Robot’s touch sensor so that:
1. Our robot knows when it meets an obstacle, and stops its motors
2. Our Robot goes backwards to give it enough room to turn away from the line
3. Our Robot turns away from the line, about 70 – 80 degrees
4. Our robot starts moving forwards “around the obstacle”,
5. Our robot stops moving “around the obstacle” when it finds the line on the other side of the obstacle

Sample Obstacle Avoidance Code

A sample code that works with our robot is shown below. You will see that we have connected our light sensor to slot 3. NOTE: Your code, light values, sensor and motor connections will probably be different, so be careful if you decide to follow this code!

Where would we place this obstacle avoidance code?

We could place this “Avoid Obstacle” (or “Avoid Water Tower”) code just before the “Line Follow Code”, as suggested below:

To see how to add these LEGO EV3-G commands in a way that will work with our one-color-sensor Robot, watch the video below:

When we added this code to our Rescue Challenge code, our robot avoided the obstacle, as shown in the video below:

We hope that these hints give you  a step towards being able to teach your Robot to avoid obstacles between it and the person to be rescued!  Have fun! 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *