Hauptinhalt

updateSensors

Update sensor readings in UAV scenario

    Description

    updateSensors(scene) updates all sensor readings based on latest states of all platforms in the UAV scenario, scene.

    Examples

    collapse all

    Create a UAV scenario, and specify the update rate, stop time, and reference location.

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

    Add an inertial frame MAP to the scenario.

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

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

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

    Add a UAV platform with a specified waypoint trajectory to the scenario.

    traj = waypointTrajectory(Waypoints=[0 -20 -5; 20 -20 -5; 20 0 -5],TimeOfArrival=[0 1 2]); 
    uavPlat = uavPlatform("UAV",scene,Trajectory=traj); 

    Add a mesh to the UAV platform.

    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 UAV platform.

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

    Visualize the scenario in 3D.

    ax = show3D(scene); 
    axis(ax,"equal"); 

    Set up and start the scenario.

    % Set up scenario
    setup(scene); 
    
    % Start scenario
    while advance(scene) 
        % Update sensor readings 
        updateSensors(scene); 
        
        % Visualize the scenario 
        show3D(scene,"Parent",ax,"FastUpdate",true); 
        drawnow limitrate 
    end 

    Figure contains an axes object. The axes object with xlabel East (m), ylabel North (m) contains 4 objects of type patch.

    Input Arguments

    collapse all

    UAV scenario, specified as a uavScenario object.

    Version History

    Introduced in R2020b