ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosbag message instance & ros1_bridge help

asked 2018-04-09 13:30:35 -0500

Sriram gravatar image

Hi,

I was working with some tools for ros2 when I came across rosbag and it's message_instace class. On the same topic, I started understanding the ros1_bridge.

I'd like to get more detail on how ros1_bridge understands the message_instance data published by rosbag and converts the same to ros2 format and re-publishes.

Could anyone help me with docs/links or any suggestions?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-04-10 22:04:43 -0500

Geoff gravatar image

rosbag and ros1_bridge are entirely separate tools. They are only connected by the ROS communications infrastructure between them. Messages that rosbag replays look like messages published from any other source. The message_instance class is no longer relevant once a message has been published by rosbag.

If you want to learn how ros1_bridge translates messages from ROS 1 to ROS 2, you should start by looking at the ros1_bridge source code. The dynamic_bridge creates an object for each mapping between ROS 1 and ROS 2 (and in the other direction). This object stores the topic to subscribe to on the ROS 1 side, the topic to publish to on the ROS 2 side, and a pointer to a callback function. The callback function handles translating each message received. The actual translation of a specific message type is handled by a function that is generated for that message using a templating language (not C++ templates, a Python-based one). You can see the template in resource/pkg_factories.cpp.em; look for the convert_1_to_2 function. Essentially it does a recursive field-wise copy of the message data.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-04-09 13:30:35 -0500

Seen: 240 times

Last updated: Apr 10 '18