#!/bin/bash

# brun //experimental/ben/timing_analysis:obsbag_run_record obsbag_name output_bag
# terminate with control-c (terminating with q corrupts recorded bag)

if [ "$#" -ne  2 ] ; then
  echo "Usage: $0 ObsbagName OutputBag " >&2
  exit 2
fi

autonomous_topic="/vehicle/measurements"
logging_topic="/rosout"

cd $ZOOX_WORKSPACE_ROOT
bazel build //bin/...

(
rosbag record  "$autonomous_topic" "$logging_topic"  -O "$2"
) &
(
 bazel_run //sim/obstacle_bag:obsbag run $1
)

exit 0
