Bug 2
Table of contents
Working of Algorithm
Bug algorithms assume only knowledge of the environment and a global goal. Their behaviors are quite simple:
- Follow a wall (right or left)
- Move in a straight line toward goal
The “catch” here is simple as displayed in the below figure
- Head towards goal on the m-line
- If an obstacle is in the way, follow it until you encounter the m-line again closer to the goal
- Leave the obstacle and continue toward the goal
The algorithm is used when you have a mobile robot
- With a known starting location
- With a known goal location**
- An Unexplored environment
- Contains a distance sensor that can detect distances to objects and walls in the environment
- Contains an encoder that the robot can use to estimate how far the robot has traveled from the starting location
MATLAB Code
% We start by loading an obstacle field to challenge the robot
load house;
about house; % matrix is an example of occupancy grid
% list of named places within the house
place
% Assumptions:
% 1. robot operates in a grid world and occupies one grid cell
% 2. robot is capable of omnidirectional motion and can move to any of its eight neighboring grid cells
% 3. it is able to determine its position on the place which is a nontrivial problem
% we create an instance of the bug2 class
bug = Bug2(house);
% The bug2 algorithm does not use the map to plan a path – the map is used by the simulator to provide sensory inputs to the robot.
bug.plot(); % to display robot's environment
% to simulate using 'query' command and the arguments are start and goal
% position of the robot within the house.
bug.query(place.br3, place.kitchen, 'animate')
% bug.query(place.garden, place.kitchen, 'animate') % this takes very very loooong time
p = bug.query(place.br3, place.kitchen)
about p
References
- Bug 2 by automatic addison - Implemented using Python
- Howie Chest lecture slides - CMU