Uncategorized

SITL Drones | A Drone Development MUST

In the ArduPilot and PX4 worlds, testing new code on a real drone would be dangerous. What if something goes wrong while the drone is 50ft in the sky? What if a new bug makes Buster the drone nosedive into your next-door neighbor’s dog? That is where sitl comes into play. 

SITL stands for software-in-the-loop. Really it is a simulated drone running right on your computer. This way, any bugs can be found before deploying the code to an actual drone. 

What is SITL?

The features of the SITL drone are pretty vast, and many different situations can be simulated. For example, you can even test what the drone would do if it all of the sudden dropped GPS signal, which is a handy thing to know. 

Most commonly, SITL is used to test changes two basic things. First, we have testing changes made to the firmware itself, this could be ArduPilot or PX4. Let’s say you wanted to add a new flight mode to the firmware? You’d simply fork the firmware, make the changes, then spin up a SITL drone to see how it behaves. 

Alternatively, SITL is also commonly used for testing out drone apps running on python. For these apps, the drone firmware isn’t changed.

SITL Running On Computer

These high level apps leave the low level firmware unchanged, and focus on moving the drone in new and unique ways. This could be either taco delivery mission, object recognition, or any other drone app you can think of. 

Developing high level apps is much less intensive programming work, because no changes to the low level firmware are required.

SITL also works for any vehicle type that your software program supports, so rovers, boats, planes, vtols and more can be tested in SITL as well. 

Once you combine SITL with the power of MAVProxy, you have quite the powerful testing platform. 

How To Use SITL

Let’s jump into how you can spin up your own SITL vehicle in under 5 minutes.

First, we need to clone the open source firmware. We’ll use ardupilot as an example. 

git clone https://github.com/ArduPilot/ardupilot.git

Next, go into the directory and initialize the submodules. 

git submodule update – init – recursive

After this, go into the directory of the vehicle you want to simulate. So if you want to simulate a drone, cd into Copter. 

Now we can launch a SITL copter. 

../Tools/autotest/sim_vehicle.py – map – console

This will compile the source code of ArduPilot, and launch the vehicle with a map and an informational console. 

Once sim_vehicle.py is done running, it also gives you a MAVProxy session as well. 

Let’s command the SITL vehicle now for fun. 

In MAVProxy, type the following: 

arm throttle

mode guided

takeoff 10

mode land

disarm throttle

You have now commanded the SITL drone to arm the motors, change to guided mode, fly up to 10m, land and disarm the motors. I now give you a white belt in the arts of SITL.

Final Thoughts

What’s cool about this mission is that the exact same commands would work on an actual drone. This only scratches the surface of SITL, if you want to learn more about simulation and how drone programming fit together, check out this article

Leave a Reply