design obstacle avoidance package delivery scenario using uav scenario designer -凯发k8网页登录
this example shows how to rapidly design and customize a uav scenario to validate an obstacle avoidance algorithm.
the uav package delivery example uses a specific scenario modeling a few city blocks to validate the obstacle avoidance algorithm. however, you must verify that the uav can fly safely and consistently with an obstacle avoidance algorithm by simulating over different scenarios. for example, you may want to evaluate the algorithm over a denser urban setting with closely spaced buildings. these scenarios are difficult to setup without a visual reference. in this example, start with a simple scenario and gradually add layers of complexity to it by importing a terrain, more obstacles, and moving actors to the scene by using . after validating the obstacle avoidance algorithm in uav scenario designer, export and simulate in a scenario in simulink.
launch app
to start the app, click apps > uav scenario designer, or execute the uavscenariodesigner
function.
to view the final state of the scenario designed in the example, load it from the stored scenario data to workspace. to see the scenario within the app, click import scenario under the import section and import the scenario into the app. otherwise, following along with the example.
load customizedscenario;
import terrain
click import terrain > import dted terrain to import a digital terrain elevation data (dted) terrain into the app. the app shows a list of pre-registered terrains. to register a custom terrain in matlab®, use the function.
select gmted2010
from the import terrain from matlab session dialog box.
keep the reference location latitude, longitude, and altitude to the default zero values. in the property panel, set the latitude limits, and longitude limits to [-0.003 0.002]
and [-0.0015 0.0015]
respectively. click import terrain in the property panel to finish importing the terrain with these properties.
add obstacles to scenario
add simple buildings to the scene by importing 2-d polygons into the app. the 2-d polygons are represented by n-by-2 vertices that denote the x and y corner points of the polygon. this polygon is imported as a 3-d polyhedron into the app where its depth can be adjusted. some templates are provided in 'buildingtemplates.mat'.
load('buildingtemplates.mat')
click scene objects > polygonin the toolstrip and import any building. after placing them in the scenario canvas, you can adjust the height, color, and position of this polygon. adding an object on top of the terrain automatically adjusts its base to match ground elevation. if you move the object or adjust its dimensions, you can use the quick access button 'snap to ground elevation' to quickly adjust building elevation.
import building8
and place it in the uav scenario canvas. try adjusting the position of the building by clicking and dragging the object marker in uav scenario canvas.
in the property panel, set the height to 30
meters and set the color of the building to green.
click snap to ground elevation to place the modified building back onto the terrain. add more buildings to the scene following this step.
leverage toolbar controls to navigate 3-d scenario
the uav scenario view offers helpful controls to ease scenario design.
hide object markers: object markers are useful to quickly find an object in a large 3-d scene but can cause clutter in a compact and dense urban scenario. use this button to hide or reveal object markers.
visualization controls: fine tune visualization such as pan/zoom/rotate.
zoom to last selected: zooms onto the selected object/platform. you can change your selection by selecting the relevant object in the uav scenario canvas or through the scene browser.
restore view: restore default view of the scenario.
click hide object markers in both the uav scenario canvas (2-d) and uav scenario view (3-d) view to remove markers. click zoom to last selected in 2-d and 3-d while placing objects or platforms onto scene to snap focus to a specific scenario object/platform.
add uav platform to scenario
next add a uav platform to the scene. this platform will serve as a foundation to validate the obstacle avoidance algorithm in later steps. scroll within the overhead uav scenario canvas to zoom into a location. now select a quadrotor from the platform section in app toolstrip and place it into the scenario canvas. in the property panel, set the name of the platform to uav
. this makes it easier to identify the platform scenario element in the simulink model later.
to ensure the uav starts sufficiently away from obstacles, select the platform uav and click zoom to last selected in either the 2-d or 3-d view to zoom to the platform. once focused on the uav, zoom out slowly to gain a sense of the surroundings of the uav.
the default z position of the uav is the terrain height at the selected x and y position. adjust its height interactively with the time-altitude plot. click the time-altitude button in the trajectory tab. drag the altitude line vertically to interactively change the height of the platform.
add lidar to platform
click sensors > lidar to add a lidar sensor to the platform so that it can sense the obstacles to avoid. select the location of the lidar on the platform in the sensor canvas. set the update rate of the sensor to 2
hz. set the sensor name to lidar
in the property panel.
use the y-z and z-x views to place the sensor on your uav interactively. the first scene to validate the obstacle avoidance is ready.
export scenario object to matlab
export the scenario to the matlab workspace.
navigate to the main toolstrip tab uav scenario and first set update rate of the scenario to 2
hz. click export scenario to open the export scenario to workspace dialog box, and rename the scenario to scene
. click export to export the uav scenario to the workspace.
the uavscenario
object named scene
should now exist in matlab workspace.
simulate obstacle avoidance algorithm
use the basic scenario, scene
, to simulate an obstacle avoidance algorithm. open the attached simulink model customscenariopipeline
and configure this model to read the scenario parameters directly from the scenario object in workspace. run initializescenarioparam
s
to read the scenario object and populate the workspace with parameters needed by the model. this model uses the obstacle avoidance algorithm provided in uav package delivery. observe that the uav platform avoids the obstacles in the path by flying over them.
plantdatadictionary = simulink.data.dictionary.open('custompackagedelivery.sldd'); %use a predefined 'scene' designed by following previous steps provided by the example. load basicscenario %initialize scenario parameters for simulink. initializescenarioparams; %open and simulate obstacle-avoidance algorithm. simmodel='customscenariopipeline.slx'; open_system(simmodel); sim(simmodel);
the uav platform successfully flies over the obstacles and arrives at the landing area successfully. it may not always be possible to carry out such an altitude-gain maneuver in a timely fashion to avoid obstacles. customize the scenario in the next steps, to simulate other maneuvers with the obstacle avoidance algorithm.
customize package delivery scenario
to evaluate algorithm robustness, modify the scenario by:
increasing the height of buildings and building density
adding more obstacles to your scenario
adding moving actors to the scene.
by modifying the scenario in this way, the algorithm should fly around the buildings and should not react erratically to detected moving entities.
move the buildings such that they are closer together as shown in the graphic below. then adjust each building height to be 60
meters in the property panel. the height of the buildings changes from the base so click snap to ground elevation to position the objects on terrain again.
click scene object > cylinder to add a cylinders to the uav scenario canvas. add one cylinder at [-103 -73.4]
and set radius to 10
meters. add another cylinder at [3 -29]
and set radius to 5
meters.
add two quadrotors to the scene and assign trajectories such that they move towards the obstacle-avoiding platform, uav
. the second platform is red by default, and the third platform is orange by default. from the trajectory tab, add waypoints to the trajectory of the yellow quadrotor so that it circles around the cylinder at [-103 -73.4]
as shown in the figure below. design the red and yellow quadrotor trajectories to move in the general direction towards the blue platform using the figure below as reference. to enable the lidar to detect these moving actors , adjust their trajectories using the time-altitude plot to match the altitude of the blue ego platform.
the finished scene should look similar to the figure shown below. the static objects modified are highlighted. the red and yellow markers represent moving actors added to the scene.
simulate obstacle avoidance in customized scenario
simulate the efficiency of the algorithm over the customized scenario.
%load predefined scenario developed in this example. load customizedscenario; %initialize scenario parameters for simulink. initializescenarioparams; %open and simulate obstacle-avoidance algorithm. open_system(simmodel); sim(simmodel);
the uav platform successfully uses the obstacle avoidance algorithm to reach its destination. further customize the scenario as needed by repeating the last step to fine-tune and simulate your obstacle avoidance algorithm.
discardchanges(plantdatadictionary); close_system(simmodel);