Main Content

Simulate Flight Plan in Real-World Location Using Cesium

R2026b

This example shows how to simulate a flight plan created in QGroundControl in read-world location using Cesium Ion®.

The flight plan that this example uses is comprised of 4 waypoints that takes the quadcopter on a flight around the MathWorks® campus in Natick, Massachusetts.

QGroundControl map view showing a 4-waypoint flight plan around the MathWorks campus in Natick, Massachusetts

Generate Multirotor Trajectory from Flight Plan

To access the flight plan file and Simulink® model in this example, open the example live script by either clicking Open Live Script in the documentation or running openExample('uav/SimulateFlightPlanInRealWorldUsingCesiumExample').

% Create mission from flight plan file in the example.
M = uavMission(PlanFile="Survey_FlightPlan.plan");

% Show mission.
show(M);

3D plot of a UAV mission showing Start, Takeoff, Waypoint, and landing positions connected by dashed blue lines with North, East, and Up axes in meters

Create a multirotor UAV trajectory parser, and generate the trajectory.

parser = multirotorMissionParser;
trajectory = parse(parser,M);

% Show trajectory.
show(trajectory);

3D plot of a parsed multirotor UAV trajectory with waypoints marked as circles and orientation tick marks along the path in North-East-Up coordinates

Visualize Flight Trajectory in Cesium

Open the FlightPlaninCesium.slx Simulink model.

open_system("FlightPlaninCesium.slx")

The Simulink model contains "Read UAV Trajectory" block which generates translation and rotation samples for the 3D UAV Vehicle from the trajectory that you have created.

Simulink model with Read UAV Trajectory block outputting Translation and Rotation to a Simulation 3D Scene Configuration block

In the block parameter of the "Read UAV Trajectory" block, specify the Trajectory source as From trajectory object in workspace. Specify the Trajectory object as trajectory.

Read UAV Trajectory block parameters with Trajectory source set to From trajectory object in workspace and Trajectory object set to trajectory

To visualize the trajectory in Cesium, first complete the steps in Visualize with Cesium if you have not already done so. The initial setup includes creating a Cesium Ion account and access token, and creating a new token in the Simulink Authentication Manager to hold your Cesium Ion token.

Specify the following parameters for the "Simulation 3D Scene Configuration Block":

  • In the Scene tab, select Scene Source as Default Scenes.

  • In the Geospatial tab, select Enable geospatial configuration.

  • Enter your Cesium Ion token name in Access token ID.

  • Specify the Origin height, latitude, and longitude to match the takeoff coordinates.

  • To enable the OSM buildings in the visualization, populate the Additional asset ID with the Cesium OSM Building ID.

  • Select the Use advanced Sun sky.

Simulation 3D Scene Configuration block Scene tab with Scene source set to Default Scenes and Scene name set to GeospatialSimulation 3D Scene Configuration block Geospatial tab with georeference parameters, Aerial map style, and Additional asset IDs configured

To start the simulation, select Run, then allow a few seconds for the 3D visualization window to initialize. Cesium Ion takes a few additional seconds for the 3D imagery to load.

3D Cesium Ion simulation showing a quadcopter flying over buildings at the MathWorks campus

3D Cesium Ion simulation showing the quadcopter from a different angle during the flight mission

See Also

| |

Topics