ros2 / rosbag2

Apache License 2.0
285 stars 251 forks source link

Are typesupport libraries needed to be present when deserializing a message in the bag #1809

Closed karthiknit1 closed 2 months ago

karthiknit1 commented 2 months ago

Description

As ROS 2 bags are now having message definitions stored in the bag, I did not find a way to deserialize the message in the bag without loading the type support libraries for the message types stored in the bag.

For example, ROS 1 bags play the bag file even without registering the custom message type (present in the bag) by building a custom message package with the ROS Environment.

Whereas ROS 2 bags when playing just ignores the custom message type (present in the bag) without registering the custom message package with the ROS Environment. But why? The required definition is already present in the bag. How to bypass loading type support libraries for custom message, as it requires to perform colcon build on the message package (which may or may not be available to the user if the bag file is shared by other user). This is applicable to both .db3 and .mcap

I see that cdr deserializer requires typesupport libraries to be loaded for it to deserialize the message appropriately.

@r7vme, @MichaelOrlov - Correct me, if my understanding is wrong. Also, please provide an example on how to deserialize the message in C++ (without typesupport) from the bag file that contains message definition.

Expected Behavior

Behavior should be same as ROS 1 when playing the bag

Actual Behavior

I see the following warnings when playing the bag without registering the custom message.

[INFO] [1726516729.204952700] [rosbag2_storage]: Opened database 'D:/customMsgTestsqlite3/customMsgTestsqlite3_0.db3' for READ_ONLY. [WARN] [1726516729.211764300] [ROSBAG2_TRANSPORT]: Topic '/tp033bd2d3_9065_44f4_963b_92f2da38c5fe' has unknown type 'depend_msgs/msg/FullNameDepend' . Only topics with known type are supported. Reason: 'package 'depend_msgs' not found, searching: [D:\Downloads\ros2-jazzy-20240705-windows-release-amd64.zip\ros2-windows] [WARN] [1726516729.212114400] [ROSBAG2_TRANSPORT]: Topic '/tp515e517f_9f6a_49f7_a4e0_a210f92fbb95' has unknown type 'depend_msgs/msg/OneDepend' . Only topics with known type are supported. Reason: 'package 'depend_msgs' not found [WARN] [1726516729.212387300] [ROSBAG2_TRANSPORT]: Topic '/tp6ffaa37d_edf5_4721_bf8d_65e5e171063c' has unknown type 'depend_msgs/msg/NestedDepend' . Only topics with known type are supported. Reason: 'package 'depend_msgs' not found [WARN] [1726516729.212666800] [ROSBAG2_TRANSPORT]: Topic '/tpd13aabaa_f1a1_4513_9fae_3a0630817a1a' has unknown type 'depend_msgs/msg/NoDepend' . Only topics with known type are supported. Reason: 'package 'depend_msgs' not found

To Reproduce

** Steps to reproduce the behavior, e.g. Execute "ros2 bag play" on the bag file attached to reproduce the warnings.

System (please complete the following information)

Additional context

Add any other context about the problem here customMsgTestsqlite3.zip

MichaelOrlov commented 2 months ago

@karthiknit1 Yes. currently, the typesupport need to be available when desrializing message from the bag. The issue is that we have merely implemented REP-2016 Type Description Distribution (REP-2011 subset / REP-2016) - formerly "message definitions on-the-wire".

However, there are still missing parts for the ability to create publisher or subscription dynamically with those distributed type descriptions, which is supposed to be as a part of the REP-2011 Evolving message types.

The problem is not on the Rosbag2 side currently but rather the lack of support from the underlying ROS 2 core packages for this.

We already have a task Dynamic playback of locally-unknown types (rosbag#1428) and a similar task for the Dynamic Subscription (REP-2011 subset) #1374