Exploring ROS with a 2 wheeled robot #9 – Bug 0 Foil
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.
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:
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:
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:
- Go straight to the point (blue line);
- Find an obstacle;
- Circumnavigates the obstacle until it reaches the initial/entry point (light blue line);
- It’s back to the original point;
- Go to the closest point found during circumnavigation (purple line);
- Reaches the closest point;
- Go to the goal in a straight line (blue line again).
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!
- Click to share on Twitter (Opens in new window)
- Click to share on Facebook (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to email this to a friend (Opens in new window)
- Click to print (Opens in new window)
- Click to share on Google+ (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Share on Skype (Opens in new window)
- Click to share on Pinterest (Opens in new window)
- Click to share on WhatsApp (Opens in new window)
- Click to share on Telegram (Opens in new window)