Error after cloning ros1 bag

Your Environment

  1. Your operating system: Ubuntu 20.04 with ROS noetic

  2. Version of python you are running (python --version): 3.8

  3. How did you install rosbags? Did you use pip to install from PyPI or a repository checkout or something else? PyCharm with requirements.txt

  4. Version of rosbags you have installed (pip show rosbags | grep Version): rosbags.image==0.9.1

The Issue

I want to create a ROS1 bag containing images for calibration with basalt .
For test, I use a working calibration bag and just deserialize and serialize all messages and save it as simple-test-16.bag.
While this bag works with rviz, (it shows the images) it fails with basalt_calibrate, which stops with an error message.

Steps to Reproduce

  1. get calibration bag via wget http://vision.in.tum.de/tumvi/calibrated/512_16/dataset-calib-cam3_512_16.bag
  2. use testcode to 'clone' the working calibration bag
from pathlib import Path
from rosbags.rosbag1 import Writer
from rosbags.serde import serialize_ros1, serialize_cdr

with AnyReader([Path('/home/test/tumvi_calib_data/dataset-calib-cam3_512_16.bag')]) as reader, \
        Writer('simple-test-16.bag') as writer:
    # for x  in reader.connections:
    #     print(x.topic)
    # /imu0
    # /cam0/image_raw
    # /cam1/image_raw
    # /vrpn_client/raw_transform
	
    topics = dict()
    connections = reader.connections
    for connection, timestamp, rawdata in reader.messages(connections=connections):
        if connection.topic not in topics:
            conn = writer.add_connection(connection.topic, connection.msgtype)
            topics[connection.topic] = conn
        else:
            conn = topics[connection.topic] 
        msg = reader.deserialize(rawdata, connection.msgtype)
        writer.write(
            conn,
            timestamp,
            serialize_ros1(msg, msg.__msgtype__)
            # serialize_cdr(msg, msg.__msgtype__)
        )
  1. run the code to create simple-test-16.bag
  2. show the image in rviz e.g. via Image plugin and topic /cam0/image_raw
  3. get basalt via github
  4. use the simple-test-16.bag as basalt calibration source via
./basalt_calibrate --dataset-path ~/tumvi_calib_data/simple-test-16.bag --result-path ~/todelete/ --dataset-type bag --aprilgrid ~/tumvi_calib_data/aprilgrid_6x6.json --cam-types ds ds
  1. see core-dump
void rosbag::Bag::decompressRawChunk(const rosbag::ChunkHeader&) const: Assertion `chunk_header.compressed_size == chunk_header.uncompressed_size' failed.
./start-calib.sh: line 7:  5742 Aborted                 (core dumped) 

For me, it looks like that in between deserializing and (re)serializeing of ROS messages, something goes wrong in rosbags...

Edited by hermann