Exercise 1: Obstacle Avoidance
|
In Exercise 1, you learn how quadcopter determines its path around the obstacles in the scenario. The exercise consists of two steps: 1. Creating a scenario consisting of obstacles, and 2. Simulate a drone in the developed scenario in Step 1. Step 0. Setup the environment Before running the code for exercise 1, make sure to run the following command in the Command Window. This step adds the relevant folders to the path where the code for exercises is stored. This step also loads the model in the background for faster processing. >> CatchingFire_Setup |
|
Step 1. Generate the scenario This step is an interactive step where you will be using a MATLAB App to add locations for obstacles and waypoints in the scenario to be used in the later step. Run the following command to open the app >> Exercise1_Step1 |
|
|
|
scenario will be used for Step 2. |
You can close the app now by clicking on the ‘X’ on the top right corner. Observe the location of the developed scenario opened as a separate window in the MATLAB Online.
Step 2. Simulate the drone path by following obstacle avoidance
This step uses Simulink model to simulate the drone (quadcopter in this case) path by utilizing an obstacle avoidance algorithm (3D Vector Field Histogram). Type the following command to open the model to run this step
>> Exercise1_Step2
The simulation (as shown in the right picture) will automatically pop-up and start once the Simulink model gets opened. The model consists of four main subsystems:
|
|
the obstacle-free desired position and the desired yaw according to the current UAV state and point cloud data. • Controller and plant – The Controller and plant subsystem generates the control commands and updates the UAV state based on the lookahead point. |
Step 3. Monitor and observe the results
Monitor the path of the drone through the obstacles and waypoints. The parameters can be updated:
|
|
see how the drone’s path changes in the updated scenario. • Once more time permits, you can review the code to update the parameters associated with drone and the sensor mounted on the drone to analyze the change in behavior. |
Learn More
- UAV Toolbox: mathworks/uav
- UAV Obstacle Avoidance Documentation Example: mathworks/uav-obstacle-avoidance-in-simulink
- Vector Field Histogram Algorithm: mathworks/controllervfh-system-object
- Modeling and simulation: mathworks.com/discovery/modeling-and-simulation
- Simulink and Simulink Online: mathworks.com/learn/tutorials/simulink-onramp
- MATLAB App Designer: mathworks/app-designer




