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

Revision history [back]

click to hide/show revision 1
initial version

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.