Skip to content

Commit 28d9d41

Browse files
committed
ReadMe Updated
1 parent b7183d9 commit 28d9d41

9 files changed

+83
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
3+
"SettingsVersion": 1.2,
4+
"SimMode": "ComputerVision",
5+
"ViewMode": "SpringArmChase"
6+
}

Bug2/AutoPilot.py

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def Bug2(self, ):
5858
turn_start_timer = np.inf
5959
max_wait_time = 5
6060

61-
6261
turn_timer_checker = False
6362
obstacle_in_list = False
6463
use_pos_x = False

Bug2/PathPlot.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
# Connect to the quadcopter
77
client = airsim.MultirotorClient()
8-
client.enableApiControl(True)
9-
client.armDisarm(True)
10-
client.takeoffAsync(timeout_sec=0.2).join()
8+
# client.enableApiControl(True)
9+
# client.armDisarm(True)
10+
# client.takeoffAsync(timeout_sec=0.2).join()
11+
client.confirmConnection()
1112

1213

1314

Images/Bugs Example 1.PNG

73 KB
Loading

Images/Bugs Example 2.PNG

44.8 KB
Loading

Images/GIF 1.gif

3.87 MB
Loading

Images/GIF 2.gif

2.42 MB
Loading

Images/GIF 3.gif

2.63 MB
Loading

README.md

+73-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
1-
# AirSim-Multirotor-Bug2-Algorithm
2-
Python implementation of Bug2 algorithm to navigate a quadcopter/multirotor in the AirSim simulator.
1+
# Description
2+
This repository contains a python implementation of the Bug2 algorithm for path-planning and obstacle-avoidance of a multirotor in the AirSim simulator.
3+
4+
5+
## Introduction to Bug Algorithms
6+
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.
7+
There are several variations of the Bug algorithms that currently exist [[1]](#1):
8+
9+
1. **Com**: *Common Sense* algorithm, abbreviated as *Com*, 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.
10+
11+
2. **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.
12+
13+
3. **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.
14+
15+
<div style="text-align: center;">
16+
<img src="./Images/Bugs Example 1.png" alt="Bugs_1" width="800" height="276">
17+
<p>The behavior of simple Bug Algorithms.</p>
18+
</div>
19+
20+
<div style="text-align: center;">
21+
<img src="./Images/Bugs Example 2.png" alt="Bugs_1" width="800" height="291">
22+
<p>Generated paths by Bug Algorithms.</p>
23+
</div>
24+
25+
26+
## Requirements
27+
The code is written in Python 3.8 and has been tested on Windows 10 without any issues. It utilizes the following libraries:
28+
<pre>
29+
airsim==1.8.1
30+
numpy==1.22.0
31+
</pre>
32+
33+
Additionally, `Unreal Engine 4.27` is required to simulate the environment.
34+
35+
## Usage
36+
1. Clone the repository.
37+
2. Navigate to the `./AirSim_Settings` directory, then copy the `settings.json` file and paste it into the `./Users/YourUserName/Documents/AirSim` directory.
38+
3. Download the environment precompiled binaries from [here](https://drive.google.com/file/d/1TtDHg56eYTOMozV_2vU-JxoXZXwSdzbT/view?usp=sharing).
39+
4. Unzip the downloaded file, then go to the `./Environment Bug2/WindowsNoEditor` directory and launch `Environment_1.exe`.
40+
5. Navigate to `./Bug2` directory and run `AutoPilot.py` and enjoy the simulation.
41+
42+
Please note that each run may **not** always successfully complete due to potential noise in the quadcopter's movement and sensors. If a run fails, consider re-running the code.
43+
44+
#### Multirotor Trajectory Visualization
45+
In the `AutoPilot.py` script, the default setting for the `save_plot_list` variable is `True`. After a successful run, a compressed pickle file named `path_plot_points.pbz2` is generated in the `./Bug2/Saved` directory. You can visualize the trajectory points in two ways:
46+
1. Set the `plot_path_planning` variable from `False` to `True` in the script. This will continuously plot the trajectory points in real-time as the multirotor moves towards its target destination.
47+
2. Go to the `./AirSim_Settings` directory. Copy the `settings_computervision.json` file and paste it into the `./Users/YourUserName/Documents/AirSim` directory. Rename the file from `settings_computervision.json` to `settings.json`. Finally, run `./Bug2/PathPlot.py` to plot the saved trajectory points separately. You can control the camera using the keyboard's A, W, S, D, and arrow keys.
48+
49+
50+
## Showcase
51+
You can view examples of movement through the following GIFs, providing a visual showcase of navigation.
52+
<div style="display: flex;">
53+
<img src="./Images/GIF 1.gif" width="33%" />
54+
<img src="./Images/GIF 2.gif" width="33%" />
55+
<img src="./Images/GIF 3.gif" width="33%" />
56+
</div>
57+
58+
59+
#### Video Demonstration
60+
For a more in-depth demonstration, please visit [this link](https://youtu.be/486aIvB4I_c) to observe the multirotor navigation in action within the AirSim simulator.
61+
62+
63+
64+
## Acknowledgement
65+
This repository is inspired by the work of *Mohammad Hashemi*, a fellow alumnus who has implemented the Bug algorithms on a 3-wheel omnidirectional robot in the [Webots](https://cyberbotics.com/) simulator. You can find his work [here](https://github.com/mohammadhashemii/Bug-Algorithms-Simulation).
66+
67+
68+
## References
69+
70+
- <a id="1">[1]</a> [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.](https://doi.org/10.1016/j.robot.2019.103261)
71+
72+
- The environment utilized in this project is the *Modular Building Set*, which can be obtained from this [link](https://www.unrealengine.com/marketplace/en-US/product/modular-building-set/). The environment also incorporates packages such as the *Vehicle Variety Pack* available [here](https://www.unrealengine.com/marketplace/en-US/product/bbcb90a03f844edbb20c8b89ee16ea32) and the *Modular Neighborhood Pack* accessible [here](https://www.unrealengine.com/marketplace/en-US/product/modular-neighborhood-pack).
73+

0 commit comments

Comments
 (0)