Skip to content

Instantly share code, notes, and snippets.

@lucasw
Last active November 26, 2023 06:20
Show Gist options
  • Save lucasw/4aa64a6647989f5af6a2c7883341f030 to your computer and use it in GitHub Desktop.
Save lucasw/4aa64a6647989f5af6a2c7883341f030 to your computer and use it in GitHub Desktop.
Split ros bag into two
#!/bin/bash
# provide input.bag output_prefix time_fraction (0.0-1.0)
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
# thalf=`echo "($(rosbag info -y -k start output.bag) + $(rosbag info -y -k end output.bag))/2.0" | bc -l`
rosbag filter $1 $2_a.bag "t.secs <= $tfr"
rosbag filter $1 $2_b.bag "t.secs > $tfr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment