#!/bin/bash
set -x
date
if [ "$is_bag_link" == "1" ];then
echo "$bag_path is link, start to copy"
cp $bag_path "$bag_path.tmp" && mv "$bag_path.tmp" $bag_path
fi
echo "truth_json_path is: " $truth_json_path
if [ "$vehicle_type" == "special_vehicle" ]; then
dir=$(ls -l $truth_json_path |awk '/^-/ {print $NF}')
echo "truth files are: " $dir
minDate=${dir[0]}
maxDate=${dir[0]}
for i in ${dir};do
if [[ ${minDate} > $i ]];then
minDate=$i
fi
if [[ ${maxDate} < $i ]];then
maxDate=$i
fi
done
mindate=${minDate%%.*}
maxdate=${maxDate%%.*}
mindate=$((10#${mindate}-1000000))
maxdate=$((10#${maxdate}+1))
mindate=$(awk 'BEGIN{printf "%.4f\n",'$mindate'/1000000.0}')
maxdate=$(awk 'BEGIN{printf "%.4f\n",'$maxdate'/1000000.0}')
tmp_bag=${bag_path%/*}/tmp.bag
echo "min, max date: " $mindate, $maxdate, $tmp_bag
rosbag filter $bag_path $tmp_bag "t.to_sec() > ${mindate} and t.to_sec() < ${maxdate}"
mv $bag_path "$bag_path.tmp"
mv $tmp_bag $bag_path
fi
docker stats --no-stream
rosbag info $bag_path
date