ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Since there does not seem to be a solution within the ROS eco system, I wrote a script that uses rosbag decompress to go though all bag-files, detects which are broken and then reindexes them.

#!/bin/bash
decompressed_bags=/media/tneumann/fd783860-83b8-4729-8ea5-eee3e08bb9c5/trash/
reindexed_bags=/media/tneumann/fd783860-83b8-4729-8ea5-eee3e08bb9c5/reindexed/
broken_bags=""
for bag in *.bag; do
  if [[ -n $( rosbag decompress --output-dir=$decompressed_bags $bag 2>&1 > /dev/null ) ]]; then
    echo $bag
    broken_bags="$broken_bags $bag"
  fi  
  rm ${decompressed_bags}/${bag}
done

echo -e "Broken bag files:\n $broken_bags\nStart reindexing\n"
mkdir broken/

for bag in $broken_bags; do
  mv $bag broken/
  rosbag reindex --output-dir=$reindexed_bags broken/$bag
done

This is of course not my preferred solution but it works, if your bag-files are not compress this might not work, you can try to use "rosbag play -i" instead, but this just triggers an error if you also listen on the published topics.

regards
Tobias