Program a drone flight in a simulator
ActivitiesProjects
Set up a virtual quadcopter and run a simulated course that ends with a landing inside a marked zone.
You can program an autonomous drone flight without writing application code or risking real hardware. Using ArduPilot's software-in-the-loop (SITL) simulation inside Mission Planner, you plot a sequence of flight commands on a map, upload them to a virtual copter, and watch the simulated aircraft take off, follow the route, and finish the mission on screen. Running missions in simulation lets you experiment with route design and parameter changes before anything ever leaves the ground in real life.
Launching the virtual copter
Open Mission Planner's Simulation tab and choose a frame from the Model dropdown before selecting the corresponding vehicle. The order matters: leaving the frame blank defaults to a normal plane, and pairing a frame with a mismatched vehicle can produce undefined results. Starting the simulation loads default parameters and connects the virtual copter directly inside Mission Planner, with no need to clone or build ArduPilot's source code.
Building a mission that starts and ends cleanly
Switch to the Plan screen to assemble the flight row by row. Clicking the map enters latitude and longitude coordinates, and each command row exposes only the fields that command uses. Altitude is measured relative to the launch (home) position in the standard Mission Planner setup, so check the selected altitude reference if you use a different configuration.
For a Copter mission starting from the ground, give the sequence a clear beginning, route, and ending:
- Start with `TAKEOFF`: On a ground-started Copter mission, `TAKEOFF` must be the first navigation command (only a `Delay` or `Do-Aux-Function` may precede it), climbing to the height you specify relative to home.
- Plot `WAYPOINT` and `DO` commands: Each waypoint sets latitude, longitude, altitude, and an optional pause. You can also insert `DO` action commands, such as triggering a camera, alongside navigation steps.
- End with `RTL` or `LAND`: `RTL` sends the copter back toward home, normally the point where it was armed. Without a final `RTL` or `LAND` command, a Copter vehicle simply stops at the final waypoint and waits for further action.
These sequence rules apply specifically to Copter rather than every vehicle type. Once the table looks right, click Write to send the mission to the simulated vehicle, then click Read to confirm what was stored. Right-clicking the map gives you Save WP File and Load WP File for storing or reusing routes locally.
Running the flight and reading the curved path
To run the mission in the simulator under Copter's default settings, arm the virtual vehicle in another mode before switching to `AUTO` (the `AUTO_OPTIONS` parameter can change arming and takeoff behavior). For a simulated ground start under those defaults, keep throttle down, switch to `AUTO`, and then raise throttle to launch; if the simulated copter is already airborne, switching to `AUTO` starts the mission immediately. These steps are for simulation; on a physical Copter, do not attempt `AUTO` mode until `AltHold` and `Loiter` are flying well.
Watch the map and altitude or status display as the route unfolds, because the flown path can differ from sharp straight-line corners. Between ordinary waypoints in `AUTO` mode, Copter blends turns into a smooth S-curve shaped by the waypoint radius and acceleration limits. Adding a non-zero delay to a waypoint forces the copter to come to a stop there before moving on, and the smooth turn also disappears when the next command requires a halt, such as `LAND`, `LOITER_TURNS`, or `RTL`.
Two variations: mapping grids and MAVProxy
After a hand-plotted route works, you can generate a back-and-forth mapping path automatically in Mission Planner. Draw a polygon on the map, select Auto WP and Grid, and set the altitude and spacing in the dialog. Inspect the generated lines before flying them: the grid tool does not exclude an inner polygon as an island and can route across the open center of a shape that doubles back on itself.
If you already have a SITL build environment on Linux or WSL2—the setup required when simulating your own code—you can launch `sim_vehicle.py` to run the simulator with MAVProxy's console and map instead. In that workflow, take off in `GUIDED` mode, load a saved route with `wp load` or right-click the map and choose Mission | Draw to click a waypoint-only path (connecting lines appear after the second click), switch to `AUTO` once airborne, and track altitude in the console.
