Rosbag read error
Hello,
I have a rosbag with two topics. when i use rosbag play there were no errors. however i use bag.read_messages()
it gives the following error. I am new to ros can help me solving this issue. ros reindex and filter also gives the smae error.
Traceback (most recent call last):
File "createheader.py", line 11, in <module>
for topic, msg, t in bag1.read_messages(topics=['gsmsg']):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2679, in read_messages
yield self.seek_and_read_message_data_record((entry.chunk_pos, entry.offset), raw, return_connection_header)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2826, in seek_and_read_message_data_record
header = _read_header(f)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2001, in _read_header
return _build_header_from_str(header, req_op)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 2015, in _build_header_from_str
raise ROSBagFormatException('Error reading header field: expected %d bytes, read %d' % (size, len(header)))
rosbag.bag.ROSBagFormatException: Error reading header field: expected 38 bytes, read 34
Asked by panand2000 on 2019-09-21 08:29:30 UTC
Answers
I'm going to guess the bag file was made in an older version of ROS. If it wasn't melodic then the message definitions could have changed, in which case see this link for what to do http://wiki.ros.org/rosbag/migration (you can probably get away with rosbag check and rosbag fix)
Asked by Jari on 2019-09-21 16:58:39 UTC
Comments
Thanks for the reply. Yes, the bag file is generated in ros kinetic. I tried rosbag fix and check. but both gave same error. even I tried in ros kinetic it also gave same error. Can you pls give some example for generating rules.
Asked by panand2000 on 2019-09-22 01:19:35 UTC
What are the message types?
Asked by Jari on 2019-09-25 09:27:06 UTC
messages are std_msgs/String type
rosbag info data16_58_16.bag path: data16_58_16.bag version: 2.0 duration: 3:46s (226s) start: Sep 13 2019 16:58:17.36 (1568357897.36) end: Sep 13 2019 17:02:04.16 (1568358124.16) size: 295.5 KB messages: 2286 compression: none [1/1 chunks] types: std_msgs/String [992ce8a1687cec8c8bd883ec73ca41d1] topics: gsmsg 2059 msgs : std_msgs/String phenommsg 227 msgs : std_msgs/String
Also while playing this bag while says to wait 0.2 s
rosbag play data16_586.bag [ INFO] [1569473422.396778060]: Opening data16_58_16.bag
Waiting 0.2 seconds after advertising topics... done.
Hit space to toggle paused, or 's' to step. [RUNNING] Bag Time: 1568357897.357594 Duration: 0.000000 / 226.807380 [RUNNING] Bag Time: 1568357897.357795 Duration: 0.000201 / 226.807380 [RUNNING] Bag Time: 1568357897.458035 Duration: 0.100441 /
Asked by panand2000 on 2019-09-25 23:51:50 UTC
Comments