Version 0:
-------------
topic_name
md5sum
datatype
<repeating N>
  time.sec
  time.nsec
  length
  MSGDATA
-------------

Version 1.0:
-------------
#ROSLOG V1.0
quantity
<repeating quantity>
  topic_name
  md5sum
  datatype
<repeating N>
  topic_name
  time.sec
  time.nsec
  length
  MSGDATA
-------------

Version 1.1:
-------------
#ROSLOG V1.1
<repeating N>
  topic_name
  md5sum
  datatype
  time.sec
  time.nsec
  length
  MSGDATA
-------------

Alternative Version 1.1:
-------------
#ROSRECORD V1.1
<repeating N>
  topic_name
  md5sum
  datatype
  time.sec
  time.nsec
  length
  MSGDATA
-------------

Version 1.2:
-------------
#ROSRECORD V1.2
file header
  op=2
  index_pos=index_1.pos
  ---
  <empty> (padded with ' ' to 4KB)

msg_def_1
msg_1
msg_2
...
msg_N

index_1
  ver=0
  topic=topic
  count=count
  ---
  timestamp_1, uncompressed_byte_offset_1
  timestamp_2, uncompressed_byte_offset_2
  ...
  timestamp_N, uncompressed_byte_offset_N

index_2
  ...

Version 2.0:
-------------
#ROSBAG V2.0
file_header
  op=3
  index_pos=msg_def_1.pos      # position of index
  conn_count=conn_count        # total number of distinct connections in the bag
  chunk_count=chunk_count      # total number of chunks in the bag
  ---
  <empty> (padded with ' ' to 4KB)

chunk_1
  op=5
  compression=bz2              # type of compression (optional)
  size=<uncompressed bytes>    # size of data when uncompressed (optional)
  ---
  conn_1i
    op=7
    topic=topic
    id=0
    ---
    topic=topic
    message_definition=
    type=
    md5sum=
    latching=1
    callerid=caller1234
  msg_1
    op=2
    topic=...
    time=...
    conn=...
    ---
    <serialized msg>
  msg_2
    op=2
    topic=...
    time=...
    conn=...
    ---
    <serialized msg>

  ...

  msg_N

chunk_index_1.0
  op=4
  ver=1
  conn=conn
  count=count
  ---
  timestamp_1, uncompressed_byte_offset_1
  timestamp_2, uncompressed_byte_offset_2
  ...
  timestamp_N, uncompressed_byte_offset_N

chunk_index_1.1
  op=4
  ver=1
  conn=conn
  count=count
  ---
  ...

chunk_2
  op=5
  compression=bz2
  size=<uncompressed bytes>
  ---
  msg_N+1
  msg_N+2
  ...
  msg_N+M

chunk_index_2.0
  op=4
  ver=1
  conn=conn
  count=count
  ---
  timestamp_N+1, uncompressed_byte_offset_1
  timestamp_N+2, uncompressed_byte_offset_2
  ...
  timestamp_N+M, uncompressed_byte_offset_N+M

...

conn_1
  op=7
  id=0
  ---
  latching=1
  callerid=caller1234 

msg_def_1
  op=1
  topic=
  type=
  md5sum=
  def=
  ---
  <empty>

msg_def_2
  op=1
  topic=
  type=
  md5sum=
  def=
  ---
  <empty>

...

chunk_info_1
  op=6
  ver=1
  chunk_pos=chunk_1.pos
  start=start_stamp_1
  end=end_stamp_1
  count=K
  ---
  conn_1, count_1
  conn_2, count_2
  ...
  conn_K, count_K

chunk_info_2
  ...

...
<eof>
