Main Content


Generate UAV simulation scenario


    The uavScenario object generates a simulation scenario consisting of static meshes, UAV platforms, and sensors in a 3-D environment.


    scene = uavScenario creates an empty UAV scenario with default property values. The default inertial frames are the north-east-down (NED) and the east-north-up (ENU) frames.

    scene = uavScenario(Name,Value) configures a uavScenario object with properties using one or more Name,Value pair arguments. Name is a property name and Value is the corresponding value. Name must appear inside quotes. You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN. Any unspecified properties take default values.

    Using this syntax, you can specify the UpdateRate, StopTime, HistoryBufferSize, ReferenceLocation, and MaxNumFrames properties. You cannot specify other properties of the uavScenario object, which are read-only.


    expand all

    Simulation update rate, specified as a positive scalar in Hz. The step size of the scenario when using an advance object function is equal to the inverse of the update rate.

    Example: 2

    Data Types: double

    Stop time of the simulation, specified as a nonnegative scalar. A scenario stops advancing when it reaches the stop time.

    Example: 60.0

    Data Types: double

    Maximum number of steps stored in scenario, specified as a positive integer greater than 1. This property determines the maximum number of frames of platform poses stored in the scenario. If the number of simulated steps exceeds the value of this property, then the scenario stores only latest steps.

    Example: 60

    Data Types: double

    Scenario origin in geodetic coordinates, specified as a 3-element vector of scalars in the form [latitude longitude altitude]. latitude and longitude are geodetic coordinates in degrees. altitude is the height above the WGS84 rereference ellipsoid in meters.

    Data Types: double

    Maximum number of frames in the scenario, specified as a positive integer. The combined number of inertial frames, platforms, and sensors added to the scenario must be less than or equal to the value of this property.

    Example: 15

    Data Types: double

    This property is read-only.

    Current simulation time, specified as a nonnegative scalar.

    Data Types: double

    This property is read-only.

    Indicate whether the scenario is running, specified as true or false. After a scenario simulation starts, it runs until it reaches the stop time.

    Data Types: logical

    This property is read-only.

    Transformation information between all the frames in the scenario, specified as a transformTree object. This property contains the transformation information between the inertial, platform, and sensor frames associated with the scenario.

    Data Types: object

    This property is read-only.

    Names of the inertial frames in the scenario, specified as a vector of strings.

    Data Types: string

    This property is read-only.

    UAV platforms in the scenario, specified as an array of uavPlatform objects.

    Object Functions

    setupPrepare UAV scenario for simulation
    advanceAdvance UAV scenario simulation by one time step
    updateSensorsUpdate sensor readings in UAV scenario
    restartReset simulation of UAV scenario
    addInertialFrameDefine new inertial frame in UAV scenario
    addMeshAdd new static mesh to UAV scenario
    showVisualize UAV scenario in 2-D
    show3DVisualize UAV scenario in 3-D


    collapse all

    Create a UAV scenario and set its local origin.

    scene = uavScenario("UpdateRate",200,"StopTime",2,"ReferenceLocation",[46, 42, 0]); 

    Add an inertial frame called MAP to the scneario.

    scene.addInertialFrame("ENU","MAP",trvec2tform([1 0 0])); 

    Add one ground mesh and two cylindrical obstacle meshes to the scenario.

    scene.addMesh("Polygon", {[-100 0; 100 0; 100 100; -100 100],[-5 0]},[0.3 0.3 0.3]);
    scene.addMesh("Cylinder", {[20 10 10],[0 30]}, [0 1 0]); 
    scene.addMesh("Cylinder", {[46 42 5],[0 20]}, [0 1 0], "UseLatLon", true); 

    Create a UAV platform with a specified waypoint trajectory in the scenario. Define the mesh for the UAV platform.

    traj = waypointTrajectory("Waypoints", [0 -20 -5; 20 -20 -5; 20 0 -5],"TimeOfArrival",[0 1 2]); 
    uavPlat = uavPlatform("UAV",scene,"Trajectory",traj); 
    updateMesh(uavPlat,"quadrotor", {4}, [1 0 0],eul2tform([0 0 pi])); 
    addGeoFence(uavPlat,"Polygon", {[-50 0; 50 0; 50 50; -50 50],[0 100]},true,"ReferenceFrame","ENU"); 

    Attach an INS sensor to the front of the UAV platform.

    insModel = insSensor(); 
    ins = uavSensor("INS",uavPlat,insModel,"MountingLocation",[4 0 0]); 

    Visualize the scenario in 3-D.

    ax = show3D(scene); 

    Simulate the scenario.

    while advance(scene) 
        % Update sensor readings 
        % Visualize the scenario 
        drawnow limitrate 

    Introduced in R2020b