This page will guide you through the installation of the requirements for running the workshop exercises and it will explain how ROS 2, Gazebo and PX4 will interact.
The three main components are:
- GZ HARMONIC
- ROS 2 Jazzy or ROS 2 Humble
- PX4 v1.18.0 simulator
In addition to them, two extra components are required for visualization and remote control:
- QGroundControl. GQC provides intuitive operator control of PX4 drones, it lets you configure PX4, calibrate the drone sensors and plan mission. QGC is already installed in the Docker images. However, it requires GUI to enabled for the container. If this is not possible (currently for MAC) then QGC will have to be installed on the host system.
- Foxglove. Foxglove will make visualizing the drone state and perceived environment a more user friendly way.
All the instructions and all the provided scripts have been tested on Ubuntu 24.04.
Refer to PX4 Gazebo SITL documentation to clone PX4 repo, install the PX4 build dependencies, build the project and start a Gazebo Simulation.
note: PX4 Gazebo simulation with cameras you might encounter a memory leak due caused by the PX4 gstreamer plugin. See PX4/PX4-Autopilot#27296 Disable the plugin if you see it happening.
Download QGC
-
Create a ROS 2 workspace
mkdir -p ~/workspaces/px4_roscon26_ws/src cd ~/workspaces/px4_roscon26_ws/src git clone -b develop git@github.com:Dronecode/roscon-25-workshop.git px4-roscon-workshop
-
Install ROS 2 Jazzy: https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html. Pick
ros-jazzy-desktop.Alternatively, use ROS 2 Humble: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debs.html. Pick
ros-humble-desktop. -
Install the ROS 2 developer tools
sudo apt install ros-dev-tools
-
Clone the dependencies
cd ~/workspaces/px4_roscon26_ws vcs import src < ./src/px4-roscon-workshop/jazzy.repos
or, if you are using ROS Humble
cd ~/workspaces/px4_roscon26_ws vcs import src < ./src/px4-roscon-workshop/humble.repos
-
Install dependencies
cd ~/workspaces/px4_roscon26_ws source /opt/ros/jazzy/setup.bash # source /opt/ros/hummble/setup.bash rosdep install -i --from-paths src --skip-keys OpenCV
-
Build the workspace
cd ~/workspaces/px4_roscon26_ws source /opt/ros/jazzy/setup.bash # source /opt/ros/hummble/setup.bash colcon build --symlink-install
PX4 can directly connect to GZ using the gz-transport libraries.
This means that PX4 can control any GZ model as long as the model uses the required sensor and actuation plugins.
For this workshop we will use:
- the x500 quadrotor model
- the standard vtol model
- the special differential rover model
Change folder to where PX4 was cloned and run
make px4_sitl gz_x500The Gazebo GUI window will open
Before taking off you just need to connect QGC to your simulated drone.
Simply start QGC, open a terminal into the folder where you downloaded it and run
./QGroundControl-x86_64.AppImageOn the PX4 terminal you will see the message
INFO [mavlink] partner IP: 172.17.0.1
INFO [commander] Ready for takeoff!This is all you need to do to start the GZ + PX4 simulation, you can now takeoff!
With the simulation up an running, it is time to bridge ROS 2 with Gazebo and PX4.
The following sections will demo the essential steps in this process. However, when trying the exercises you can leverage the common launchfile which automatically sets up the required bridges.
-
Clock bridging. We want to leverage the GZ clock and use it to time all our ROS 2 node. This is accomplished by first creating an unidirectional bridge between the gz
/clocktopic and the ROS 2 one and then by commanding all ROS 2 to use the newly created/clockROS 2 topic as time reference. We will use theros_gz_bridgepackage to create the bridge:ros2 run ros_gz_bridge parameter_bridge /clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock
While the ROS 2 behavior will be set by the parameter
use_sim_time. -
ROS 2 - PX4 bridge. PX4 leverages eProsima Micro XRCE-DDS which internal PX4 messages to be directly exposed to the ROS 2 network. The simulated PX4 instance automatically start the Micro XRCE-DDS client using UDP protocol on port 8888, what we need to do is to just start the agent with the same settings.
MicroXRCEAgent udp4 -p 8888
after running this command you can see PX4 establish the connection - the expected output is a sequence of messages like
INFO [uxrce_dds_client] successfully created rt/fmu/out/vehicle_status_v1 data writer, topic id: 279 INFO [uxrce_dds_client] successfully created rt/fmu/out/airspeed_validated data writer, topic id: 14 INFO [uxrce_dds_client] successfully created rt/fmu/out/vtol_vehicle_status data writer, topic id: 288 INFO [uxrce_dds_client] successfully created rt/fmu/out/home_position data writer, topic id: 123
Now that the PX4 messages are available to ROS 2, you can list them with
ros2 topic listThe messages in the topics with namespace /fmu/in are sent from ROS 2 to PX4 while the ones with namespace /fmu/out go from PX4 to ROS 2.
For example, you can check the PX4 vehicle status with
ros2 topic echo /fmu/out/vehicle_status_v4You can use the px4_tf packages, in conjunction with foxglove_bridge to visualize in 3D the drone base_link.
The px4_tf_publisher node subscribes to PX4 /fmu/out/vehicle_odometry topic and publishes a derived transform for the odom frame to the base_link frame.
ros2 run px4_tf px4_tf_publisher --ros-args -p use_sim_time:=trueFinally foxglove_bridge let's us visualize the tf in Foxglove.
ros2 run foxglove_bridge foxglove_bridge --ros-args -p use_sim_time:=trueLaunch your Foxglove client and open a connection of type Foxglove WebSocket with url ws://localhost:8765.
Note: when restarting the simulations and the foxglove_bridge, you might have to restart Foxglove client too to re-establish the connection.

