Skip to content

Commit

Permalink
add simple evaluate-scenario script
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Haas committed Feb 5, 2024
1 parent 499eead commit 000f3c2
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
56 changes: 56 additions & 0 deletions automated-testing/evaluate-scenarios.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions automated-testing/template.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 000f3c2

Please sign in to comment.