Repository Summary

Description ROS2 Humble desktop workspace for integration with PX4 simulation
Checkout URI https://github.com/ark-electronics/px4_ros2_examples_ws.git
VCS Type git
VCS Version main
Last Updated 2025-03-11
Dev Status UNKNOWN
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
custom_mode 0.0.1

README

ROS2 & PX4 CustomMode example

This tutorial is a example on how to utilize custom modes in PX4 using ROS2 and QGC. We would like to provide you with a basic example code that you can customize and utilize for your application.

This project is a customized example of the usage of the Auterions PX4-ROS2 Interface Library

https://github.com/Auterion/px4-ros2-interface-lib

Video Walkthrough

Software

https://youtu.be/L1RO0oUdzqI

Hardware

https://www.youtube.com/watch?v=Sw24kesfpLw

Prerequisites

  • Ubuntu 22.04
  • ROS2 Humble
  • PX4 Autopilot
  • Micro XRCE-DDS Agent
  • QGroundControl Daily Build

You can find the required instructions collected below

https://docs.px4.io/main/en/ros2/user_guide.html

https://docs.qgroundcontrol.com/master/en/qgc-user-guide/releases/daily_builds.html

You can also have a look on our previous tutorial where the steps above are covered:

https://github.com/ARK-Electronics/ROS2_PX4_Offboard_Example

Usage

Setup the Workspace

Make sure you source ROS2 Humble in the terminal you are using.

source /opt/ros/humble/setup.bash

OR Just add the line above to your bashrc, in that case it is going to be sourced every time you open a terminal.

nano ~/.bashrc

Navigate to the directory you would like to place the worskpace and then run the following

git clone https://github.com/ARK-Electronics/px4_ros2_examples_ws

Then navigate into the workspace:

cd px4_ros2_examples_ws

Install the submoduls

git submodule update --init --recursive

Build the workspace

colcon build

After this runs, we do not need to build the whole workspace again, you can just build the individual packages you have modified

colcon build --packages-select custom_mode

Source the workspace

source install/setup.bash 

Run the example

Run the simulation environment

To ensure message compatibility, make sure you are using the same PX4 version as shown in the video. To do this, follow these steps:

cd PX4-Autopilot
git fetch origin
git checkout 8070c70
git submodule update --init --recursive

cd PX4-Autopilot/
make px4_sitl_default gz_x500

Run the Micro XRCE-DDS Agent for the communication stream

MicroXRCEAgent udp4 -p 8888

Run QGC Daily build

Navigate to the directory

./QGroundControl.AppImage

Take off with the drone using the GUI

Launch your custom mode

File truncated at 100 lines see the full file