Aerostack2

DocsGetting Started

Quickstart

Fly a simulated drone with a short Python mission in about ten minutes.

Authored by
  • @alvgaona

In this guide you start a simulated drone and fly it around a square with a Python script. It uses the multirotor simulator, a lightweight simulator that doesn't need Gazebo, and the ready-made multirotor simulator project.

Before you start

  • Aerostack2 is installed. Any method in Installation works. Keep the environment sourced in each terminal you open, or use pixi run as shown below.
  • tmux and tmuxinator are installed. The project uses them to start every component in its own terminal pane. The Docker images already include them.
sudo apt install tmux tmuxinator

Fly your first mission

Get the project

git clone https://github.com/aerostack2/project_as2_multirotor_simulator.git
cd project_as2_multirotor_simulator

A project holds the configuration files, launch scripts and missions for one application. Every Aerostack2 example is organized this way.

Start the drone

./launch_as2.bash

With Pixi, the first run downloads and builds the environment for the project, so it takes a while.

This opens a tmux session called drone0 with one window per group of components:

WindowWhat runs there
platformThe multirotor simulator, acting as the drone's aerial platform
basics_robotics_functionsThe state estimator and the motion controller
behaviorsTake off, land, go to, follow path, trajectory generation and gimbal behaviors
mission_executionThe behavior tree runner, used by mission_behavior_tree.py
mission_monitoringThe alphanumeric viewer, which shows the drone's state

You land on mission_monitoring. Press Ctrl-b followed by a window number to look at the others.

Open the ground station (optional)

In a second terminal, from the project folder:

./launch_ground_station.bash

This opens RViz, where you can watch the drone move.

Run the mission

In another terminal, from the project folder:

python3 mission.py

The drone arms, takes off to 1 m and flies around a 4 × 4 m square twice. On the second lap it turns to face the direction it's flying. Then it lands. The script reports each step as it goes:

Running mission for drone drone0
Start mission
Arm
Arm success: True
Offboard
Offboard success: True
Take Off
Take Off success: True
Run mission
Go to with keep yaw [-2.0, 2.0, 1.0]
Go to success: True
...
Land
Land success: True
Manual
Manual success: True
Clean exit

Stop everything

./stop.bash

This closes the drone and ground station sessions.

What the mission does

Without the printing and error checks, mission.py comes down to this:

mission.py (simplified)
import rclpy
from as2_python_api.drone_interface import DroneInterface

rclpy.init()
drone = DroneInterface(drone_id="drone0")

drone.arm()
drone.offboard()
drone.takeoff(height=1.0, speed=1.0)

square = [[-2.0, 2.0, 1.0], [-2.0, -2.0, 1.0], [2.0, -2.0, 1.0], [2.0, 2.0, 1.0]]
for point in square:
    drone.go_to.go_to_point(point, speed=1.0)

drone.land(speed=0.5)
drone.manual()

drone.shutdown()
rclpy.shutdown()
  • DroneInterface connects to the drone running under the drone0 namespace.
  • arm() starts the motors, and offboard() hands control of the drone to Aerostack2.
  • takeoff(), go_to.go_to_point() and land() each run a behavior. They wait until the behavior finishes and return True if it succeeded.
  • Points are [x, y, z] in metres, in the drone's earth frame. The drone starts at the origin.
  • manual() hands control back to the platform, and shutdown() closes the connection.

Try changing the points or the speeds, then run the mission again. The drone stack doesn't need restarting between runs.

Next steps

The project includes more missions. Run them the same way as mission.py:

MissionWhat it shows
mission_behavior_tree.pyStarts the behavior tree in trees/square.xml, which the drone loaded at launch, and flies a 3 × 3 m square
mission_interpreter.pyA mission written as JSON and run by the mission interpreter
mission_gps.pyFlying to GPS coordinates instead of local positions
mission_swarm.pySeveral drones at once. Start the drones with ./launch_as2.bash -m and the ground station with ./launch_ground_station.bash -m first

Last updated on November 3, 2026

On this page

Last updated on November 3, 2026