#!/bin/bash
# Sets various params required for teleop's vehicle discovery
# Runs chum_play using the topics in teleop_topics.py
# All args are passed to chum_play
# Must be run within the bazel workspace

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

builtin cd "$(bazel info workspace)"
bazel_run //teleop/launch:set_zrn_ros_param -- "$@"
topics=$(python -c "print ','.join(open('teleop/launch/teleop_topics.txt','r').readlines())")
bazel_run //bin:chum_play -- --topics "$topics" "$@"
