Rosbag1 protobuf mcap Serialization and deserialization #1248
Replies: 1 comment
-
If you want to reinterpret a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a question, I want to convert the data of type std_ msgs/String in Rosbag into an MCAP file. The std_ msgs/String message is obtained by serializing protobuf type data. At this time, the proto version used is 3.0.0, and the ROS version is Melodic. This version of Rosbag only supports Python 2, while MCAP requires a minimum of Python 3.8. Therefore, I deployed the Noetic version of ROS in Docker (which supports Python 3 in Rosbag) and successfully installed MCAP related libraries. However, the minimum version requirement for protobuf is 3.19, so I installed the 3.19 version of protobuf again. When I tried to deserialize and convert to MCAP, I encountered the following problem
`
import rosbag
import argparse
from mcap_protobuf.writer import Writer
from header_pb2 import Header
from object_pb2 import TrackedObjects
from object_pb2 import TrackedObject
import std_msgs.msg
class TransBagToMcap:
def init(self, from_path, save_dir):
self.from_path = from_path
self.save_dir = save_dir
self.serialize_topics = ["/perception/lidar/lidar_obstacle"]
if name == 'main':
parser = argparse.ArgumentParser(description='Convert ROS bag file to MCAP file.')
parser.add_argument('--bag_path', type=str, required=True, help='Path to the input ROS bag file')
parser.add_argument('--output_path', type=str, required=True, help='Path to the output MCAP file')
args = parser.parse_args()
Traceback (most recent call last):
File "rosbag_to_mcap.py", line 37, in
trans_bag_to_mcap.convert_bag_to_mcap()
File "rosbag_to_mcap.py", line 19, in convert_bag_to_mcap
track_objects.ParseFromString(msg.data)
TypeError: expected bytes, str found
`
`
Environment for generating bags:
/usr/bin/protoc --version
libprotoc 3.0.0
ros: Melodi
Environment for convert bags:
protoc --version
libprotoc 3.19.0
ros:Noetic
`
Beta Was this translation helpful? Give feedback.
All reactions