forked from osrf/ariac-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_trial.bash
executable file
·64 lines (51 loc) · 2.21 KB
/
run_trial.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
#
# Only works with ROS Kinetic
#
set -e
# Constants
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NOCOLOR='\033[0m'
# Arguments
TEAM_NAME=$1
TRIAL_NAME=$2
SERVER_IMAGE_NAME="ariac-server-flatten-${ROS_DISTRO}"
COMPETITOR_IMAGE_NAME="ariac-competitor-${TEAM_NAME}"
# Create the directory that logs will be copied into. Since the userid of the user in the container
# might different to the userid of the user running this script, we change it to be public-writable.
HOST_LOG_DIR=`pwd`/logs/${TEAM_NAME}/${TRIAL_NAME}
echo "Creating directory: ${HOST_LOG_DIR}"
mkdir -p ${HOST_LOG_DIR}
chmod 777 ${HOST_LOG_DIR}
# TODO: don't rely on script being run in the root directory
# TODO: error checking for case when files can't be found
TEAM_CONFIG_DIR=`pwd`/team_config/${TEAM_NAME}
echo "Using team config: ${TEAM_CONFIG_DIR}/team_config.yaml"
COMP_CONFIG_DIR=`pwd`/trial_config
echo "Using comp config: ${COMP_CONFIG_DIR}/${TRIAL_NAME}.yaml"
ROS_DISTRO=kinetic
LOG_DIR=/ariac/logs
# Ensure any previous containers are killed and removed.
./kill_ariac_containers.bash
# Create the network for the containers to talk to each other.
./ariac-competitor/ariac_network.bash
# Start the competitors container and let it run in the background.
./ariac-competitor/run_competitor_container.bash ${COMPETITOR_IMAGE_NAME} "/run_team_system_with_delay.bash" &
# Start the competition server. When the trial ends, the container will be killed.
# The trial may end because of time-out, because of completion, or because the user called the
# /ariac/end_competition service.
CONTAINER_NAME=ariac-server-system
./ariac-server/run_container.bash ${CONTAINER_NAME} ${SERVER_IMAGE_NAME}:latest \
"-v ${TEAM_CONFIG_DIR}:/team_config \
-v ${COMP_CONFIG_DIR}:/ariac/trial_config \
-v ${HOST_LOG_DIR}:${LOG_DIR} \
-e ARIAC_EXIT_ON_COMPLETION=1" \
"/run_ariac_task.sh /ariac/trial_config/${TRIAL_NAME}.yaml /team_config/team_config.yaml ${LOG_DIR}"
# Copy the ROS log files from the competitor's container.
echo "Copying ROS log files from competitor container..."
docker cp --follow-link ${COMPETITOR_IMAGE_NAME}-system:/root/.ros/log/latest $HOST_LOG_DIR/ros-competitor
echo -e "${GREEN}OK${NOCOLOR}"
./kill_ariac_containers.bash
exit 0