Main Content

uavMission

Mission data for UAV flight

    Description

    The uavMission object stores UAV mission data that can be used to generate flight trajectories for use in UAV scenario simulation.

    Creation

    Description

    M = uavMission creates an empty mission, M.

    example

    M = uavMission(PlanFile=file) creates a mission from the specified mission plan file file.

    example

    M = uavMission(___,Name=Value) specifies properties using one or more name-value arguments in addition to any combination of input arguments from previous syntaxes.

    Input Arguments

    expand all

    Mission plan file path, specified as a string scalar or character vector. You must specify either a PX4 Mission JSON file (.plan) or MAVLink waypoints file (.waypoints).

    Example: uavMission(PlanFile="documents/matlab/uavwpts.waypoints")

    Data Types: char | string

    Properties

    expand all

    Home location, specified as a three-element row vector of the form [latitude longitude altitude]. The first two elements specify the latitude and longitude, respectively, of the UAV starting location in degrees, and the third specifies the starting altitude of the UAV in meters.

    Example: uavMission(HomeLocation=[4 2 10])

    Initial yaw angle, specified as a numeric scalar. This property specifies the angle between the x-axis of the UAV and north direction in the local NED frame of the mission's home location, in degrees.

    Example: uavMission(InitialYaw=45)

    Reference speed of the UAV, specified as a numeric scalar in meters per second.

    Example: uavMission(Speed=5)

    Data Types: double

    Mission waypoint reference frame, specified as one of these values:

    • "Global" — Global reference frame

    • "GlobalRelativeAlt" — Global reference frame with an altitude relative to the home location

    • "LocalENU" — Local east-north-up (ENU) reference frame

    • "LocalNED" — Local north-east-down (NED) reference frame

    Example: uavMission(Frame="Global")

    Data Types: char | string

    Number of mission items stored as a nonnegative integer. NumMissionItems increments each time a mission item is added to the mission.

    This property is read-only.

    Object Functions

    addChangeSpeedAdd change speed mission item
    addHoverAdd hover mission item
    addLandAdd landing mission item
    addLoiterAdd loiter mission item
    addTakeoffAdd takeoff mission item
    addWaypointAdd waypoint mission item
    copyCopy UAV Mission
    removeItemRemove mission items at specified indices
    showVisualize UAV mission
    showdetailsUAV mission data table

    Examples

    collapse all

    Create a UAV mission by using the flight plan stored in a .plan file and show the mission.

    mission = uavMission(PlanFile="flight.plan");
    show(mission);

    Figure contains an axes object. The axes object contains 10 objects of type line, text.

    Create parsers for a multirotor UAV and a fixed-wing UAV.

    mrmParser = multirotorMissionParser(TransitionRadius=2,TakeoffSpeed=2);
    fwmParser = fixedwingMissionParser(TransitionRadius=15,TakeoffPitch=10);

    Generate one flight trajectory using each parser.

    mrmTraj = parse(mrmParser,mission);
    fwmTraj = parse(fwmParser,mission);

    Visualize the mission and the flight trajectories separately.

    figure
    subplot(1,2,1)
    show(mrmTraj);
    title("Multirotor Trajectory")
    axis square
    subplot(1,2,2)
    show(fwmTraj);
    title("Fixed-Wing Trajectory")
    axis square

    Figure contains 2 axes objects. Axes object 1 with title Multirotor Trajectory contains 501 objects of type patch, line. Axes object 2 with title Fixed-Wing Trajectory contains 428 objects of type patch, line.

    Plot the mission and flight trajectories overlapping.

    figure
    show(mission);
    hold on
    show(mrmTraj);
    hold off
    title("Mission Using Multirotor Trajectory")
    axis square

    Figure contains an axes object. The axes object with title Mission Using Multirotor Trajectory contains 511 objects of type patch, line, text.

    show(mission);
    hold on
    show(fwmTraj);
    hold off
    title("Mission Using Fixed-Wing Trajectory")
    axis square

    Figure contains an axes object. The axes object with title Mission Using Fixed-Wing Trajectory contains 438 objects of type patch, line, text.

    Create a UAV mission object with a home location at the origin of the local ENU coordinate frame and an initial speed of 5 meters per second.

    m = uavMission(Frame="LocalENU",HomeLocation=[0 0 0],Speed=5)
    m = 
      uavMission with properties:
    
           HomeLocation: [0 0 0]
             InitialYaw: 0
                  Frame: "LocalENU"
                  Speed: 5
        NumMissionItems: 0
    
    

    Add a takeoff mission item to the mission with an altitude of 25 meters, pitch of 15 degrees, and yaw of 0 degrees.

    addTakeoff(m,20,Pitch=15,Yaw=0);

    Add two waypoint mission items to the mission. Between the two waypoints, increase the speed of the UAV to 20 meters per second. After the second waypoint, reduce the speed of the UAV back to 5 meters per second.

    addWaypoint(m,[10 0 30]);
    addChangeSpeed(m,20)
    addWaypoint(m,[20 0 40]);
    addChangeSpeed(m,5)
    addWaypoint(m,[30 0 50])

    Add loiter and hover mission items to the mission, specifying for the UAV to loiter and hover around the second waypoint at a radius of 50 meters for 20 seconds each.

    addLoiter(m,[40 0 60],10,20);
    addHover(m,[50 0 70],10,20);

    Add a landing mission item to the mission to land the UAV.

    addLand(m,[70 0 0],Yaw=0);

    Show the mission item data table.

    showdetails(m)

    Remove the hover action at index 7, and then add another waypoint at index 8 after the hover item moves to index 7. Show the mission details table again to see the changes.

    removeItem(m,7);
    addWaypoint(m,[65 0 70],InsertAtRow=8);
    showdetails(m)

    Visualize the mission.

    show(m);
    axis equal

    Figure contains an axes object. The axes object contains 10 objects of type line, text.

    Version History

    Introduced in R2022b