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

Revision history [back]

Here is a bash script to split a bag into two using a parameter from 0.0 to 1.0- 0.5 would produce two half length bags:

#!/bin/bash
# provide input bag, output bags prefix, and time fraction
echo $1, $2, $3
t0=`rosbag info -y -k start $1`
t1=`rosbag info -y -k end $1`
tfr=`echo "$t0 + ($t1 - $t0) * $3" | bc -l`
echo $t0, $t1, $tfr
rosbag filter $1 $2_a.bag "t.secs <= $tfr"
rosbag filter $1 $2_b.bag "t.secs > $tfr"