Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ros1_bridge function for converting generic message types #377

Merged

Conversation

dbking77
Copy link
Contributor

@dbking77 dbking77 commented Aug 26, 2022

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
Copy link
Member

gbiggs commented Aug 28, 2022

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 dbking77 marked this pull request as draft September 13, 2022 15:37
@dbking77 dbking77 changed the title RIOT-13229 : ros1_bridge function for converting generic message types ros1_bridge function for converting generic message types Sep 13, 2022
@dbking77 dbking77 force-pushed the dbking77/riot13229/ros_bag_bridge branch 3 times, most recently from 43de119 to a73c8e2 Compare October 13, 2022 19:08
@dbking77 dbking77 marked this pull request as ready for review October 13, 2022 19:08
@dbking77 dbking77 force-pushed the dbking77/riot13229/ros_bag_bridge branch from a73c8e2 to bdc064f Compare October 13, 2022 21:32
@dbking77
Copy link
Contributor Author

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

@@ -149,14 +157,14 @@ class Factory : public FactoryInterface
topic_name, qos, callback, options);
}

void convert_1_to_2(const void * ros1_msg, void * ros2_msg) override
void convert_1_to_2(const void * ros1_msg, void * ros2_msg) const override
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like function should be const, but it this causes compatibility problems, or should be left non-const I'm happy to change it back.

src/shape_shifter_access.cpp Outdated Show resolved Hide resolved
src/shape_shifter_access.cpp Outdated Show resolved Hide resolved
@dbking77 dbking77 force-pushed the dbking77/riot13229/ros_bag_bridge branch from bdc064f to 4ac055d Compare October 15, 2022 03:54
@dbking77 dbking77 force-pushed the dbking77/riot13229/ros_bag_bridge branch from 4ac055d to ced30d7 Compare October 15, 2022 04:30
@dbking77
Copy link
Contributor Author

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

@gbiggs
Copy link
Member

gbiggs commented Nov 1, 2022

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@gbiggs
Copy link
Member

gbiggs commented Nov 1, 2022

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

Build Status

@gbiggs gbiggs merged commit 81f8b08 into ros2:master Nov 3, 2022
@gbiggs
Copy link
Member

gbiggs commented Nov 3, 2022

Thanks for the contribution!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants