- Notifications
You must be signed in to change notification settings - Fork3
Python implementation of Bug2 algorithm to navigate a quadcopter/multirotor in the AirSim simulator.
License
MehdiShahbazi/AirSim-Multirotor-Bug2-Algorithm
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository contains a python implementation of the Bug2 algorithm for path-planning and obstacle-avoidance of a multirotor in the AirSim simulator.
Bug algorithms belong to a category of path-planning methods that take inspiration from maze-solving algorithms. They are specifically designed to navigate in environments with no knowledge about obstacles and rely solely on the relative positioning of their target. These algorithms move towards their destination by following the boundaries of obstacles they encounter.There are several variations of the Bug algorithms that currently exist[1]:
Com:Common Sense algorithm, abbreviated asCom, initiates by tracing the shape of the object, but it quickly deviates from its path when it has the opportunity to head straight towards the goal. In general, this algorithm doesn't ensure that the robot will reach its destination successfully.
Bug 1: When confronted with an obstacle, Bug 1 starts by exploring the obstacle's entire border while simultaneously figuring out the nearest position to the target. After reaching this initial point of contact, Bug 1 moves towards the closest position to the target and then deviates from the obstacle at that specific point. Bug 1 excels in environments where Com's performance falls short.
Bug 2: Bug 1 tends to generate longer paths than necessary because it needs to map the entire border of the obstacle. However, Bug 2 introduces a new concept called M-line, which is an imaginary line drawn between the starting and target positions. Bug 2 follows along the obstacle's border until it reaches the same M-line on the opposite side. If the point on this M-line is closer to the target than where it currently hit the obstacle, Bug 2 will then navigate away from it.
The code is written in Python 3.8 and has been tested on Windows 10 without any issues. It utilizes the following libraries:
airsim==1.8.1numpy==1.22.0
Additionally,Unreal Engine 4.27 is required to simulate the environment.
- Clone the repository.
- Navigate to the
./AirSim_Settingsdirectory, then copy thesettings.jsonfile and paste it into the./Users/YourUserName/Documents/AirSimdirectory. - Download the environment precompiled binaries fromhere.
- Unzip the downloaded file, then go to the
./Environment Bug2/WindowsNoEditordirectory and launchEnvironment_1.exe. - Navigate to
./Bug2directory and runAutoPilot.pyand enjoy the simulation.
Please note that each run maynot always successfully complete due to potential noise in the quadcopter's movement and sensors. If a run fails, consider re-running the code.
In theAutoPilot.py script, the default setting for thesave_plot_list variable isTrue. After a successful run, a compressed pickle file namedpath_plot_points.pbz2 is generated in the./Bug2/Saved directory. You can visualize the trajectory points in two ways:
- Set the
plot_path_planningvariable fromFalsetoTruein the script. This will continuously plot the trajectory points in real-time as the multirotor moves towards its target destination. - Go to the
./AirSim_Settingsdirectory. Copy thesettings_computervision.jsonfile and paste it into the./Users/YourUserName/Documents/AirSimdirectory. Rename the file fromsettings_computervision.jsontosettings.json. Finally, run./Bug2/PathPlot.pyto plot the saved trajectory points separately. You can control the camera using the keyboard's A, W, S, D, and arrow keys.
You can view examples of movement through the following GIFs, providing a visual showcase of navigation.
For a more in-depth demonstration, please visitthis link to observe the multirotor navigation in action within the AirSim simulator.
This repository is inspired by the work ofMohammad Hashemi, a fellow alumnus who has implemented the Bug algorithms on a 3-wheel omnidirectional robot in theWebots simulator. You can find his workhere.
K. N. McGuire, G. C. de Croon, and K. Tuyls, “A comparative study of bug algorithms for robot navigation,” Robotics and Autonomous Systems, vol. 121, p. 103261, 2019.
The environment utilized in this project is theModular Building Set, which can be obtained from thislink. The environment also incorporates packages such as theVehicle Variety Pack availablehere and theModular Neighborhood Pack accessiblehere.
About
Python implementation of Bug2 algorithm to navigate a quadcopter/multirotor in the AirSim simulator.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.


