See the Bug 0 Foil

Step 0 – Introduction

In this post, we are checking the failure of the Bug 0 algorithm! What is this about?
Bug 0 is not a perfect motion planning algorithm! And at the end of this post, we show how it could be improved using Bug 1. Let’s start!

(If you don’t have the previous post ROSJect, you can copy it from here!)

Step 1 – Check Bug 0 Failure

The first thing is launching a simulation with a new world we have created for this post. It’s an extensive file and it doesn’t make sense, for this post, to explain its code. Please copy the file from here! Paste its content to a new file: ~/simulation_ws/src/my_worlds/worlds/world03.world

And change the launch file at ~/simulation_ws/src/my_worlds/launch/world.launch. Set the value of the argument world to “world03”.

Launch the world as before, from ROSDS simulation menu, choose my_worlds world.launch from the dropdown. You must have the simulation below running.

Exploring ROS with a 2 wheeled robot #9 – Bug 0 Foil image 1

Next step: Spawn the robot. Let’s use the very same command, just pay attention to the arguments:

roslaunch m2wr_description spawn.launch y:=8

Which must be at the position shown below, more or less:

Exploring ROS with a 2 wheeled robot #9 – Bug 0 Foil image 2

Start the Bug 0 algorithm and watch it fail:

roslaunch motion_plan bug0.launch des_x:=0 des_y:=-3

Again, pay attention to the arguments, we are sending the robot to the center of the maze.

 

Step 2 – What is happening to Bug 0?

If everything went as expected, you should have seen something like this:

Exploring ROS with a 2 wheeled robot #9 – Bug 0 Foil image 3

It turns out Bug 0 can’t handle such kind of “maze” (It’s not a challenging maze if we know the map, but for an algorithm without a map, it is!). Bug 0 is always turning to the same side (left or right). That’s why it never reaches the goal.

How can we get rid of it?

Step 3 – Introducing Bug 1

There is another motion planning algorithm, this one called Bug 1. The description of its behavior is:

  • The robot tries to go straight to the point;
  • If there is an obstacle, the robot circumnavigates it, in order to find the closest point, from the obstacle to the goal;
  • When the robot reaches back the initial point, it goes to the closest point noted previously;
  • From the closest point, the robot tries again going in a straight line to the goal.

And it works in a loop, check below how Bug 1 would perform the task at the same environment:

Exploring ROS with a 2 wheeled robot #9 – Bug 0 Foil image 4

  1. Go straight to the point (blue line);
  2. Find an obstacle;
  3. Circumnavigates the obstacle until it reaches the initial/entry point (light blue line);
  4. It’s back to the original point;
  5. Go to the closest point found during circumnavigation (purple line);
  6. Reaches the closest point;
  7. Go to the goal in a straight line (blue line again).

Conclusion

We could see how Bug 0 can fail and also a better algorithm to solve the problem. For the next post, what if you try to implement the Bug 1 algorithm using some of the functions we have created so far?

If something went wrong up to here, you can copy the ROSJect here!

 

See you!

[irp posts=”13469″ name=”Exploring ROS with a 2 wheeled robot #8 – Bug 0″]