Copter SITL/MAVProxy Tutorial¶
The article is intended primarily for developers who want to test new
Copter builds and bug fixes using SITL and MAVProxy. It shows how to
take off, fly in
GUIDED mode, run missions, set a geofence, and
perform a number of other basic testing tasks.
The tutorial is complementary to the topic Using SITL for ArduPilot Testing.
cd ~/ardupilot/ArduCopter ../Tools/autotest/sim_vehicle.py --map --console
If you wish to start the simulation at a different map location or use a different frame type (-f option for hexa,tri,octa,heli,etc.) than a standard + layout quadcopter, see SITL Advance Testing. A complete list of startup options for the simulator can be found using the –help option:
The MAVProxy Command Prompt, Console and Map should be arranged conveniently so you can observe the status and send commands at the same time.
This section explains how to take off in
GUIDED mode. The main steps
are to change to
GUIDED mode, arm the throttle, and then call the
takeoff command. Takeoff must start within 15 seconds of arming, or
the motors will disarm!
At time of writing, Copter only supports takeoff in guided mode;
if you want to fly a mission you first have to take off and then switch
AUTO mode. From AC3.3 it will be possible to take off in AUTO
Enter the following commands in the MAVProxy Command Prompt.
mode guided arm throttle takeoff 40
Copter should take off to an altitude of 40 metres and then hover (while it waits for the next command).
During takeoff you can watch the altitude increase on the console in the Alt field.
Developers may find it useful to graph the takeoff by first entering
The most common sources of difficulty taking off are:
- Starting in any mode other than
- Attempting to takeoff when the vehicle is not armed. This can happen
if you call
takeofftoo slowly after
arm throttle, or if the vehicle fails pre-arm checks.
You can list all enabled checks using the command
LAND> arm list LAND> all params voltage compass battery ins rc baro gps
You can enable and disable checks using
arm check n and
arm uncheck n respectively, where n is the name of the check. Use
n value of of
all to enables/disable all checks.
Changing flight mode - circle and land¶
The command below shows how to put Copter into CIRCLE mode with a CIRCLE_RADIUS of 2000cm. This will fly the Copter in a circle at a constant altitude, with the front pointed towards the centre of the circle.
mode circle param set circle_radius 2000
If you set the
CIRCLE_RADIUS to zero the vehicle will rotate
Copter supports a number of other flight modes,
which you can list in MAVProxy using the
LAND> mode LAND> ('Available modes: ', ['RTL', 'POSHOLD', 'LAND', 'OF_LOITER', 'STABILIZE', 'AUTO', 'GUIDED', 'DRIFT', 'FLIP', 'AUTOTUNE', 'ALT_HOLD', 'LOITER', 'POSITION', 'CIRCLE', 'SPORT', 'ACRO'])
As shown above, you can change the mode by specifying
Many of the modes can be set by just entering the mode name, e.g.
For example, to land right where you are you would use the command:
mode land. To return to the launch point and then land you would use
Guiding the vehicle¶
Once you’ve taken off you can move the vehicle around the map in
GUIDED mode. The easiest way to do this is to right-click on the map
where you want to go, select Fly to, and then enter the target
You can also enter the target position manually on the command line using the two formats below. If only the altitude is specified, the last specified LAT/LON will be used.
guided ALTITUDE guided LAT LON ALTITUDE
In addition to
takeoff, you can send the following commands in
setyaw ANGLE ANGULAR_SPEED MODE (MODE is 0 for "absolute" or 1 for "relative") setspeed SPEED_VALUE velocity x y z (m/s)
Flying a mission¶
You can load a mission at any time using the
wp load command. After
you’ve taken off the current mission will start as soon as you change to
The example below shows how to load and start one of the test missions, skip to the second waypoint, and loop the mission:
wp load ..\Tools\autotest\Generic_Missions\CMAC-circuit.txt mode auto wp set 2 wp loop
The MAVProxy Waypoints documentation lists the full set of available commands (or you can get them using auto-completion by typing “wp” on the command line).
If you want to create a waypoint mission, this is most easily done on the map:
Right-click on the map and then select Mission | Draw.
Left-click on the map where you want the points to appear.
Nothing visible will happen when you make the first click. After the second click, lines will join your points to show the path.
When you’re done, you can loop the mission by right-clicking on the map and selecting Mission | Loop.
This approach only allows you to create
commands. You can edit missions and use other commands on Linux using
the misseditor module (
module load misseditor). This is currently
broken on Windows. It is also possible to load other types of commands
Setting a GeoFence¶
A GeoFence is is a virtual barrier that Copter uses to constrain the movement of the vehicle. Copter uses a simple “tin can border” as described in Simple GeoFence. When the radius or maximum altitude is breached, Copter returns to the launch point and/or lands.
The fence is enabled (and its type selected) using the Copter Fence Parameters.
You can list the fence parameters with
GUIDED> param show fence* GUIDED> FENCE_ACTION 1.000000 FENCE_ALT_MAX 100.000000 FENCE_ENABLE 0.000000 FENCE_MARGIN 2.000000 FENCE_RADIUS 150.000000 FENCE_TYPE 3.000000
The fence has an altitude boundary of 100 metres (
is bound by a circle of radius
FENCE_RADIUS around the home
FENCE_TYPE=3 means that both the radius and altitude
are used (you can change the type to other numbers have an altitude-only
or circle only fence - or none at all).
The fence is initially disabled (
FENCE_ENABLE=0). To turn it on we
set the value to one:
GUIDED> param set fence_enable 1
When we fly outside the radius the mode changes to RTL (return to land).
If for some reason we travel further out by the value of
FENCE_MARGIN, then the vehicle will simply land.
Testing the vehicle¶
MAVProxy allows you to list all the parameters affecting the vehicle
and simulation using
param show *, and to set any parameter using:
param set PARAM_NAME VALUE. In addition to affecting the vehicle
itself some parameters simulate the performance/failure of specific
hardware components and the environment (for example, the wind). These
can be listed using:
param show sim*. The topic Using SITL for ArduPilot Testing explains more about how
you can test using SITL.