MCPcopy Create free account
hub / github.com/Auterion/px4-ros2-interface-lib

github.com/Auterion/px4-ros2-interface-lib @2.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.1.1 ↗ · + Follow
1,018 symbols 1,831 edges 183 files 166 documented · 16% updated 11d ago2.1.1 · 2026-05-19★ 17712 open issues

Browse by type

Functions 813 Types & classes 205
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PX4 ROS 2 Interface Library

Library to interface with PX4 from a companion computer using ROS 2. It provides some tooling used to write external modes that are dynamically registered with PX4 and behave the same way as internal ones. A mode can send different types of setpoints, ranging from high-level navigation tasks all the way down to direct actuator controls.

The library is written in C++, with Python bindings provided as well (not yet complete).

Documentation: - High-level: https://docs.px4.io/main/en/ros2/px4_ros2_interface_lib.html - API: - C++: https://auterion.github.io/px4-ros2-interface-lib/topics.html - Python: https://auterion.github.io/px4-ros2-interface-lib/python/px4_ros2_py.html

Compatibility with PX4

The library interacts with PX4 by using its uORB messages, and thus requires a matching set of message definitions on the ROS 2 side. To ensure compatibility, you must either:

  1. Use latest main on the PX4 and px4_ros2/px4_msgs sides, which should define matching messages
  2. (Experimental) Run the PX4 message translation node, which dynamically monitors and translates PX4 messages when different message version are used within the same ROS 2 domain
  3. There are branches in the form of release/<version> matching the PX4 releases. For example https://github.com/Auterion/px4-ros2-interface-lib/tree/release/1.16

Option 1: Match Messages

The library checks for message compatibility on startup when registering a mode. ALL_PX4_ROS2_MESSAGES defines the set of checked messages. If you use other messages, you can check them using:

if (!px4_ros2::messageCompatibilityCheck(node, {{"fmu/in/vehicle_rates_setpoint"}})) {
  throw std::runtime_error("Messages incompatible");
}

To manually verify that two local versions of PX4 and px4_msgs have matching message sets, you can use the following script:

./scripts/check-message-compatibility.py -v path/to/px4_msgs/ path/to/PX4-Autopilot/

Option 2: Translate Messages

If you intend to run the message translation node to use mismatching message versions in PX4 and px4_ros2/px4_msgs, then you must manually disable the message compatibility check that runs when registering a mode. This can be done the following way:

class CustomMode : public px4_ros2::ModeBase
{
public:
  CustomMode(rclcpp::Node & node)
  : ModeBase(node, "node_name")
  {
    setSkipMessageCompatibilityCheck();  // Disables compatibility check
    ...
  }
  ...
};

Examples

There are code examples under examples/cpp for C++ and examples/python for Python.

Development

For development, install the pre-commit scripts:

pre-commit install

CI

CI runs a number of checks which can be executed locally with the following commands. Make sure you have the ROS workspace sourced.

clang-tidy

./scripts/run-clang-tidy-on-project.sh

Unit tests

You can either run the unit tests through colcon:

colcon test --packages-select px4_ros2_cpp --ctest-args -R unit_tests
colcon test-result --verbose

Or directly from the build directory, which allows to filter by individual tests:

./build/px4_ros2_cpp/px4_ros2_cpp_unit_tests --gtest_filter='xy*'

Linters (code formatting etc)

These run automatically when committing code. To manually run them, use:

pre-commit run -a

Core symbols most depended-on inside this repo

Shape

Method 683
Class 179
Function 130
Enum 26

Languages

C++96%
Python4%

Modules by API surface

px4_ros2_cpp/include/px4_ros2/mission/mission_executor.hpp50 symbols
px4_ros2_cpp/src/mission/mission_executor.cpp46 symbols
px4_ros2_cpp/test/unit/mission_execution.cpp40 symbols
px4_ros2_cpp/include/px4_ros2/mission/actions/default_actions.hpp32 symbols
px4_ros2_cpp/src/components/mode_executor.cpp24 symbols
px4_ros2_cpp/test/integration/mode_executor.cpp22 symbols
px4_ros2_cpp/src/components/mode.cpp21 symbols
px4_ros2_cpp/test/unit/mission_execution.hpp20 symbols
px4_ros2_cpp/test/integration/overrides.cpp19 symbols
px4_ros2_cpp/include/px4_ros2/mission/mission.hpp17 symbols
px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp17 symbols
px4_ros2_cpp/include/px4_ros2/components/mode.hpp16 symbols

For agents

$ claude mcp add px4-ros2-interface-lib \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page