ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Dynamic message publishers and subscribers

Open luca-della-vedova opened this issue 5 months ago • 0 comments

This PR revives #262 from @nnmm (as evident from the first commit that actually does 95% of the work!), with a few minor updates:

  • Solve whatever merge conflict from 3 years ago and bring up to date with latest supported ROS distros.
  • Migrate to the new pub/sub async workers APIs.
  • Make some of the public API a bit more robust (i.e. introduce a struct for message types rather than having to rely on strings).
  • Add tests for basic pub / sub behavior to validate that this is actually working.

I'll admit that most of the code under field_access (where the casting and reinterpreting of arbitrary messages is done) is a bit out of my comfort zone, however loopback tests, message serialization and deserialization seem to work so it is at least doing something sensible.

Following the initial implementation this is all under a dyn_msg feature flag, but I'm not 100% convinced that the additional [cfg(feature = "dyn_msg")] directives that are scattered throughout the codebase are worth it. Specifically on my (very overpowered) machine a clean build with dyn_msg enabled builds a total of 93 packages while a clean build without the feature builds 89 packages. The compile time difference itself is hard to detect.

Originally, the PR was split into a separate one that only included the message structure. I'm happy to split this into smaller chunks if that makes it easier to review but I thought I would show what a full implementation looks like first.

This only tackles messages, publishers and subscribers. Services (and actions) are left as a future implementation.

luca-della-vedova avatar Jun 24 '25 08:06 luca-della-vedova