ros2 / ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
Apache License 2.0
425 stars 275 forks source link

ros1_bridge function for converting generic message types #377

Closed dbking77 closed 1 year ago

dbking77 commented 1 year ago

This adds functions to convert between generic message types for ROS1 (ShapeShifter) and ROS2 (SerializedMessage)

This is useful for custom bag recording tools. For us specifically, there is a tool (action_monitor) that records certain topics at specific times based on the current robot action. If robot is idle, we record very few topics. If robot is navigating, we record many more topics. We'de like to extend this tool to record both ROS1 and ROS2 topics at the same time to a ROS1 bag format. If we just used dynamic_bridge to bridge all ROS2 topics, we'de pay heavy penalty bridging unnecessary topics when robot is idle.

To subscribe to an arbitrary ROS2 topic, rclcpp provides create_generic_subscription which invokes a callback that takes SerializedMessage. Because there is no concrete type at compile time we cannot use convert_2_to_1. Because each ros1_bridge::Factory is templated on both ROS1 and ROS2 message types, it has all the concrete type information to perform the generic message conversion.

gbiggs commented 1 year ago

Please update your PR's description with information about what new feature you are implementing and why. You also should add some tests of the new functionality.

dbking77 commented 1 year ago

@gbiggs I added PR description and unit tests. Could you approve the testing workflow?

dbking77 commented 1 year ago

@gbiggs I replaced shape_shifter with a vector buffer this does reduce dependencies and simplify stuff quite a bit. Can I get a testing retrigger?

gbiggs commented 1 year ago

CI:

gbiggs commented 1 year ago

Whoops, wrong CI configuration. Let's try that again.

Build Status

gbiggs commented 1 year ago

Thanks for the contribution!