Skip to content

Commit

Permalink
update readme, revert disabling message compat
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeLaine authored and bkueng committed Feb 6, 2025
1 parent 2722626 commit b7dfd9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PX4 ROS 2 Interface Library

Library to interface with PX4 from a companion computer using ROS 2.
It provides some tooling to used to write external modes that are dynamically registered with PX4 and behave the same way as internal ones.
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.

Documentation:
Expand All @@ -10,7 +10,12 @@ Documentation:

## 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.
Compatibility is only guaranteed if using latest `main` on the PX4 and px4_ros2/px4_msgs side. This might change in the future.
To ensure compatibility, you must either:

1. Use latest `main` on the PX4 and px4_ros2/px4_msgs sides, which should define matching messages
1. (Experimental) Run the PX4 [message translation node](https://github.com/PX4/PX4-Autopilot/tree/message_versioning_and_translation/msg/translation_node), which dynamically monitors and translates PX4 messages when different message version are used within the same ROS 2 domain

### 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:
Expand All @@ -26,6 +31,25 @@ To manually verify that two local versions of PX4 and px4_msgs have matching mes
./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:

```c++
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/modes](examples/cpp/modes).
Expand Down
7 changes: 2 additions & 5 deletions px4_ros2_cpp/include/px4_ros2/components/mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ class ModeBase : public Context
RequirementFlags & modeRequirements() {return _health_and_arming_checks.modeRequirements();}

protected:
void setSkipMessageCompatibilityCheck(bool skip = true)
{
_skip_message_compatibility_check = skip;
}
void setSkipMessageCompatibilityCheck() {_skip_message_compatibility_check = true;}
void overrideRegistration(const std::shared_ptr<Registration> & registration);

private:
Expand Down Expand Up @@ -194,7 +191,7 @@ class ModeBase : public Context
std::shared_ptr<Registration> _registration;

const Settings _settings;
bool _skip_message_compatibility_check{true};
bool _skip_message_compatibility_check{false};

HealthAndArmingChecks _health_and_arming_checks;

Expand Down

0 comments on commit b7dfd9a

Please sign in to comment.