Skip to content

Instantly share code, notes, and snippets.

View trunc8's full-sized avatar

Siddharth Saha trunc8

View GitHub Profile
@lucasw
lucasw / split_bag.sh
Last active November 26, 2023 06:20
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"