#!/bin/bash
# Playback all data that was received by the robot proxy from a specific vehicle
#
# To view the raw data, use tools like rostopic_proto but be aware that the ros topics
# will be a straight translation of the dds namespace convention:
#     planner__hero_state if the vehicle topic was /planner/hero_state
#
# To view in TeleDash, use robot proxy mode on the same LAN
#
# Usage:
# ./teleop/launch/robot_proxy_play.sh <robot_name> <chum argument 1>...<chum argument N>
# ./teleop/launch/robot_proxy_play.sh kitt_01 --start_time 1545084196 --end_time 1545084250 --loop

set -euo pipefail

trap 'kill -TERM $(jobs -p) &>/dev/null; wait &>/dev/null; exit 130' INT
trap 'kill -TERM $(jobs -p) &>/dev/null; wait &>/dev/null' EXIT

# Find workspace and set up env
workspace=$(bazel info workspace)
source "$workspace/scripts/shell/bazel/function.sh"

chum_play_args="${@:2}"

ZOOX_VEHICLE_CONFIG=/etc/zoox/calibration/param/${1}.json bazel_run //teleop/launch:robot_proxy_play_launch -- chum_robot_name:=${1} chum_play_args:="${chum_play_args}"
