From 499eead90b7ff295650f6638f8b86b2f8bdd12ba Mon Sep 17 00:00:00 2001 From: Benedikt Haas Date: Mon, 5 Feb 2024 18:24:36 +0100 Subject: [PATCH 1/2] add simple demo run --- .github/workflows/automated-testing.yml | 4 ++-- automated-testing/docker-compose.yml | 28 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 automated-testing/docker-compose.yml diff --git a/.github/workflows/automated-testing.yml b/.github/workflows/automated-testing.yml index 1ac2127..e210733 100644 --- a/.github/workflows/automated-testing.yml +++ b/.github/workflows/automated-testing.yml @@ -29,7 +29,7 @@ jobs: with: scenario-folder-path: ${{ matrix.filedir }} scenario-file-name: ${{ matrix.filename }} - simulator-image: carla-health # TODO: Change to rwthika/carla:server + simulator-image: carla-health # TODO: Change to rwthika/carla-simulator:server simulator-offscreen: false generate-opt-scenario-job-matrix: @@ -62,5 +62,5 @@ jobs: with: scenario-folder-path: ${{ matrix.filedir }} scenario-file-name: ${{ matrix.filename }} - simulator-image: carla-health # TODO: Change to rwthika/carla:server + simulator-image: carla-health # TODO: Change to rwthika/carla-simulator:server simulator-offscreen: false diff --git a/automated-testing/docker-compose.yml b/automated-testing/docker-compose.yml new file mode 100644 index 0000000..3e5262e --- /dev/null +++ b/automated-testing/docker-compose.yml @@ -0,0 +1,28 @@ +services: + + carla-simulator: + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + environment: + DISPLAY: $DISPLAY + XAUTHORITY: /.Xauthority + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + - $XAUTHORITY:/.Xauthority:ro + privileged: True + image: carla-health # TODO: Change to rwthika/carla-simulator:server + command: bash -ic './CarlaUE4.sh -nosound $SIMULATOR_FLAGS 2>/dev/null' + + carla-scenario-runner: + depends_on: + carla-simulator: + condition: service_healthy + volumes: + - ../utils/scenarios:/scenarios + image: rwthika/carla-scenario-runner:latest + command: bash -ic "python ./scenario_runner.py --host carla-simulator --openscenario /scenarios/town10.xosc.opt --output" From 000f3c21cc1d640e89ad5fc2ce1ab23fa907f492 Mon Sep 17 00:00:00 2001 From: Benedikt Haas Date: Mon, 5 Feb 2024 19:14:12 +0100 Subject: [PATCH 2/2] add simple evaluate-scenario script --- automated-testing/evaluate-scenarios.sh | 56 +++++++++++++++++++++++++ automated-testing/template.yml | 28 +++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 automated-testing/evaluate-scenarios.sh create mode 100644 automated-testing/template.yml diff --git a/automated-testing/evaluate-scenarios.sh b/automated-testing/evaluate-scenarios.sh new file mode 100755 index 0000000..fba73e1 --- /dev/null +++ b/automated-testing/evaluate-scenarios.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +set -e + +usage() { + echo "Usage: $0 [-d maxdepth] [-e exclude-path] STARTING-POINT QUERY-STRING" + echo "STARTING-POINT : Location from where search should start" + echo "QUERY-STRING : UNIX pattern used for matching and selecting results. Needs to be \"quoted\"" + echo "max-depth : Descend at most max-depth levels from STARTING-POINT" + echo "exclude-string : Exclude paths matching this UNIX pattern from final result. Needs to be \"quoted\"" + echo "-----" + echo "Example: $0 -d 3 . \"*.xosc\"" +} + +trap cleanup EXIT +trap cleanup 0 + +cleanup() { + echo "Cleaning up..." + docker compose -f $COMPOSE_TEMPLATE_PATH kill + docker compose -f $COMPOSE_TEMPLATE_PATH down + xhost -local: + echo "Done cleaning up." +} + +restart-simulator() { + echo "Restarting simulator..." + docker compose -f $COMPOSE_TEMPLATE_PATH kill + docker compose -f $COMPOSE_TEMPLATE_PATH down + docker compose -f $COMPOSE_TEMPLATE_PATH up -d carla-simulator +} + +export SCENARIO_DIRECTORY="${1:-"../utils/scenarios"}" +export COMPOSE_TEMPLATE_PATH="${2:-"./template.yml"}" +echo $SCENARIO_DIRECTORY + +scenarios=($(find $SCENARIO_DIRECTORY -maxdepth 1 -type f -name "*.xosc*" -exec basename {} \;)) + +if [ ${#scenarios[@]} -eq 0 ]; then + echo "No scenarios found. Exiting..." + exit 1 +fi +xhost +local: +echo "Starting simulator..." +docker compose -f $COMPOSE_TEMPLATE_PATH up -d carla-simulator + +for scenario in "${scenarios[@]}"; do + echo "Evaluating $scenario ..." + + export SCENARIO_NAME=$scenario + docker compose -f $COMPOSE_TEMPLATE_PATH run --rm carla-scenario-runner || true + + if [ "$RESTART_SIMULATOR" = true ]; then + restart-simulator + fi +done diff --git a/automated-testing/template.yml b/automated-testing/template.yml new file mode 100644 index 0000000..4294732 --- /dev/null +++ b/automated-testing/template.yml @@ -0,0 +1,28 @@ +services: + + carla-simulator: + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + environment: + DISPLAY: $DISPLAY + XAUTHORITY: /.Xauthority + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + - $XAUTHORITY:/.Xauthority:ro + privileged: True + image: carla-health # TODO: Change to rwthika/carla-simulator:server + command: bash -ic './CarlaUE4.sh -nosound $SIMULATOR_FLAGS 2>/dev/null' + + carla-scenario-runner: + depends_on: + carla-simulator: + condition: service_healthy + volumes: + - $SCENARIO_DIRECTORY:/scenarios + image: rwthika/carla-scenario-runner:latest + command: bash -ic "python ./scenario_runner.py --host carla-simulator --openscenario /scenarios/$SCENARIO_NAME --output"