0
$\begingroup$

Rosanswers logo

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?


Originally posted by Sriram on ROS Answers with karma: 51 on 2018-04-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Geoff with karma: 4203 on 2018-04-10

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.