A fully Dockerized simulation environment for Maradrone, integrating:
- PX4 Autopilot SITL
- ROS 2 Humble
- Gazebo Harmonic
- QGroundControl
- A custom
leonardo_race_fieldsimulation world
Maradrone Simulation provides a Dockerized environment for running a PX4-based drone simulation integrated with ROS 2 and Gazebo.
The project combines the PX4 flight stack with custom ROS 2 nodes, Gazebo sensors, QGroundControl, and a custom simulation environment.
Unlike the other repositories developed for the Armando-Simulation and Fra2mo-Simulation educational framework, this project uses PX4 Autopilot SITL as the central flight-control component.
This repository has a different architecture compared to the other two repositories defined for the Armando-Simulation and Fra2mo-Simulation educational framework.
-
Armando-SimulationandFra2mo-Simulationare fully based on ROS 2 and share a similar architecture. -
This repository integrates a complete PX4 Autopilot SITL installation.
-
PX4 is maintained outside the ROS 2 workspace.
-
During the Docker image build:
PX4-Autopilotis cloned into/root/PX4-Autopilot.- The PX4 source tree remains external to the ROS 2 workspace.
- The custom
leonardo_race_fieldworld is copied directly into the PX4 sources. - Custom models are copied into
/root/PX4-Autopilot/Tools/simulation/gz/models/.
-
The overall architecture and development workflow are therefore different from the two pure ROS 2 projects.
The container is not started with the --rm option.
When the shell is exited, the container is stopped but not removed. This makes it possible to preserve changes made inside the container, which is particularly useful when modifying PX4 source code or creating and testing new configurations.
- PX4 Autopilot SITL with the
x500_depthdrone model - Custom
leonardo_race_fieldsimulation world - PX4βROS 2 communication through
px4_msgs ros_gz_bridgebuilt for Gazebo Harmonic- IMX214 camera bridged to ROS 2
- GStreamer and UDP video streaming for QGroundControl
- Fully Dockerized development and simulation environment
The following components are required on the host machine:
- Docker
- QGroundControl
- Docker permissions without
sudo(recommended)
To add the current user to the Docker group:
sudo usermod -aG docker $USERAfter adding the user to the Docker group, log out and log back in for the changes to take effect.
Clone the repository and enter its root directory:
cd /path/to/Maradrone_SimulationBuild the Docker image:
./docker_scripts/docker_build_image.shThen start the container:
./docker_scripts/docker_run_container.shThe first command builds the Docker image and prepares:
- ROS 2 Humble
- Gazebo Harmonic
ros_gz_bridge- Micro-XRCE-DDS-Agent
- The
PX4-Autopilotsource tree - The custom world and models inside PX4
If the container already exists but is stopped, the same run script can be used to start it again and enter the container:
./docker_scripts/docker_run_container.shBecause the container is not automatically removed, changes made inside it are preserved between runs.
Once inside the container, navigate to the PX4 directory:
cd /root/PX4-AutopilotStart PX4 SITL with Gazebo Harmonic:
PX4_GZ_WORLD=leonardo_race_field make px4_sitl gz_x500_depthThis command starts:
- PX4 SITL
- Gazebo Harmonic
- The custom
leonardo_race_fieldworld - The
x500_depthdrone model
Download QGroundControl from the official website:
QGroundControl Download & Install
On Linux, if using the AppImage:
cd ~/Downloads
chmod +x QGroundControl.AppImage
./QGroundControl.AppImageQGroundControl should connect to the PX4 simulation through MAVLink on:
14550
For the UDP video stream, configure QGroundControl to use:
5600
From inside the container, run:
docker exec -it maradrone_container bashThen start the GazeboβROS 2 bridge:
ros2 run ros_gz_bridge parameter_bridge \
/world/leonardo_race_field/model/x500_depth_0/link/camera_link/sensor/IMX214/image@sensor_msgs/msg/Image[gz.msgs.ImageThe IMX214 camera image is then available in ROS 2 on:
/world/leonardo_race_field/model/x500_depth_0/link/camera_link/sensor/IMX214/image
You can visualize the image using rqt_image_view:
rqt_image_viewSelect the camera topic above from the topic list.
The Docker image automatically installs the components required for PX4βROS 2 communication:
Micro-XRCE-DDS-Agentros_gz_bridge
The Micro-XRCE-DDS-Agent acts as the communication bridge between PX4 and ROS 2:
PX4
β
β uXRCE-DDS
βΌ
Micro-XRCE-DDS-Agent
β
β DDS
βΌ
ROS 2
More specifically:
- PX4 runs the
uxrce_dds_client. - The container provides the
Micro-XRCE-DDS-Agent. px4_msgsexposes PX4 message definitions to ROS 2.
In this project, the Micro-XRCE-DDS-Agent is already configured as part of the environment and does not require a separate manual startup.
Inside the container, build the ROS 2 workspace:
cd /root/ros2_ws
colcon build --packages-select px4_msgs maradrone_framework offboard_rl force_land read_rpyThen source the workspace:
source install/setup.bashExecutable:
offboard_takeoff
Publishes:
/fmu/in/offboard_control_mode
/fmu/in/trajectory_setpoint
/fmu/in/vehicle_command
Executable:
go_to_point
Subscribes to:
/fmu/out/vehicle_local_position
/fmu/out/vehicle_attitude
Publishes:
/fmu/in/offboard_control_mode
/fmu/in/trajectory_setpoint
/fmu/in/vehicle_command
Executable:
force_land
Publishes an emergency landing command through:
/fmu/in/vehicle_command
Executable:
read_rpy
Reads the vehicle attitude from:
/fmu/out/vehicle_attitude
The custom nodes can be started with:
ros2 run maradrone_framework offboard_takeoff
ros2 run offboard_rl go_to_point
ros2 run force_land force_land
ros2 run read_rpy read_rpyNote: These nodes require
px4_msgsto be built and the PX4βROS 2 communication layer to be active.
The overall communication architecture can be summarized as follows:
ββββββββββββββββββββ
β QGroundControl β
ββββββββββ¬ββββββββββ
β MAVLink
UDP 14550
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PX4 SITL β
β β
β PX4-Autopilot β
β βββ uORB β
β βββ uxrce_dds_client β
βββββββββββββββββ¬ββββββββββββββββββββββββββββ¬ββββββββββββββββ
β β
β uXRCE-DDS β Gazebo
βΌ βΌ
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
β Micro-XRCE-DDS-Agent β β Gazebo Harmonic β
ββββββββββββββ¬βββββββββββββ β leonardo_race_field β
β DDS β x500_depth β
βΌ β IMX214 camera β
βββββββββββββββββββββββββββ ββββββββββββββ¬βββββββββββββ
β ROS 2 β β
β βββββββββββββββββββββ
β px4_msgs β ros_gz_bridge
β Custom ROS 2 nodes β
βββββββββββββββββββββββββββ
- PX4-Autopilot runs the SITL flight-control stack.
- Gazebo Harmonic simulates the drone and the custom environment.
ros_gz_bridgeexposes Gazebo sensor data to ROS 2.px4_msgsprovides ROS 2 message definitions corresponding to PX4 uORB messages.- Custom ROS 2 nodes publish commands to
/fmu/in/.... - PX4 publishes vehicle state through
/fmu/out/.... - QGroundControl communicates with PX4 through MAVLink on UDP port
14550. - Camera data can be streamed through UDP port
5600for QGroundControl.
/fmu/in/offboard_control_mode
/fmu/in/trajectory_setpoint
/fmu/in/vehicle_command
/fmu/out/vehicle_local_position
/fmu/out/vehicle_attitude
This repository is not a pure ROS 2 simulation. It is a hybrid PX4 + ROS 2 system.
The main distinction is that PX4 remains the central flight-control component:
px4_msgsprovides the interface between PX4 messages and ROS 2.- Custom ROS 2 nodes send commands directly to PX4 through
/fmu/in/.... - PX4 remains responsible for the vehicle's core flight-control logic.
- Gazebo provides the simulated environment and sensor data.
- ROS 2 is used for high-level control, perception, and custom application logic.
This architecture is therefore fundamentally different from the ROS 2-only approach used by Armando-Simulation and Fra2mo-Simulation.
Maradrone_Simulation/
βββ docker_scripts/
β βββ Dockerfile
β βββ docker_build_image.sh
β βββ docker_run_container.sh
βββ src/
β βββ force_land/
β βββ maradrone_description/
β β βββ models/
β β βββ worlds/
β βββ maradrone_framework/
β βββ offboard_rl/
β βββ px4_msgs/
β βββ read_rpy/
βββ README.md
- This repository follows a different development methodology and architecture compared to
Armando-SimulationandFra2mo-Simulation. - The Dockerfile prepares the PX4 source tree and copies the custom simulation world into
/root/PX4-Autopilot. - Custom Gazebo models are installed under
/root/PX4-Autopilot/Tools/simulation/gz/models/. - The Docker container is persistent and is not removed when stopped, allowing modifications to be preserved.
- The
maradrone_framework,offboard_rl,force_land, andread_rpypackages depend onpx4_msgsand the PX4βROS 2 communication layer. - PX4 remains the central flight-control component, while ROS 2 provides the interface for custom control and application-level logic.