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 |
CI status | No Continuous Integration |
Released | UNRELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
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
I created a launch file that you can use. It currently contains only one node, so it might seem limited, but you can expand on it. The file includes three basic patterns: circle, spiral, and figure-8. These are ROS2 parameters that you can set either directly in the launch file or via command line arguments. If no pattern is specified, the default is circle.
cd px4_ros2_examples_ws/
source install/setup.bash
AND
ros2 run custom_mode custom_mode
OR
ros2 launch custom_mode custom_mode.launch.py
OR
ros2 launch custom_mode custom_mode.launch.py trajectory_type:=spiral
OR
ros2 run custom_mode custom_mode --ros-args -p trajectory_type:=figure_8
Start it from QGC
You can just start the custom node from the GUI or you can also map it to your remote control
Closing remarks
ONce you are done do not forget to close all your terminals
Video
ARK Electronics
For more open-source drone-related material, follow us on LinkedIn and Twitter:
If you’re interested in US-manufactured drone hardware, please visit our webpage:
Questions
Message Patrik Dominik Pordi on the Dronecode Foundation Discord for questions or email me at patrik@arkelectron.com