diff --git a/ail_vru_uc1_scenario/README.md b/ail_vru_uc1_scenario/README.md index f6df7f11..2382793c 100644 --- a/ail_vru_uc1_scenario/README.md +++ b/ail_vru_uc1_scenario/README.md @@ -13,9 +13,10 @@ This CARMA Configuration Image creates a **AIL** (Anything-In-the-Loop) scenario | ----------| ----------- |--------- | | 2,6 | 35 | TRUE | | 4,8 | 5 | TRUE| - -![Alt text](docs/scenario_diagram.png) - +### Scenario: West to North Left Turn (A) +![Alt text](docs/scenario_north.png) +### Scenario: South to North Through (B) +![Alt text](docs/scenario_south.png) ## Simulators | Simulator | Version | @@ -25,8 +26,13 @@ This CARMA Configuration Image creates a **AIL** (Anything-In-the-Loop) scenario ## Deployment Instructions ### Deployment Steps -TODO: Complete this section -Copy all files in the route_config directory to `/opt/carma/routes/` +1) Copy all files in the `ail_vru_uc1_scenario/cdasimconfig/route_config/` directory to `/opt/carma/routes/` +2) Navigate to `ail_vru_uc1_scenario` and `./build_image.sh` to build CARMA Config image. (Optional if remote image exists) + 1) `./build_image/sh` should print resulting image name +3) Run `carma config set ` +4) Navigate to the `cdasim_config/` directory. +5) `./run_simulation` script clears all necessary volumes and containers and runs `carma start all` +6) Launch a second terminal and run `./stop_simulation` to stop the simulation and collect data. ### Locally Built Docker Images The Virtual Signal Controller is built locally and currently only available to licenced users. diff --git a/ail_vru_uc1_scenario/cdasim_config/.env b/ail_vru_uc1_scenario/cdasim_config/.env index 7acf4a5f..cc146d4c 100644 --- a/ail_vru_uc1_scenario/cdasim_config/.env +++ b/ail_vru_uc1_scenario/cdasim_config/.env @@ -1,3 +1,16 @@ INFRASTRUCTURE_ID=rsu_1234 SIMULATION_MODE=true -TIME_SYNC_TOPIC=time_sync \ No newline at end of file +TIME_SYNC_TOPIC=time_sync +# North Destination +VEHICLE_SELECTED_ROUTE=vru_uc1_north +SIMULATION_SCENARIO="VulnerableRoadUserCollision_ThreeTrucks" + +## SCENARIOS CONFIGURATION ----------------------- +# To switch between scenarios, simply uncomment the scenario +# you would like to run and comment all other scenarios + +# SCENARIO: West to North left turn (A) +VEHICLE_SPAWN_POINT="215.12,-169,0,0,0,0" + +# SCENARIO: South to North through (B) +# VEHICLE_SPAWN_POINT="258.12,-125,0,0,0,90" \ No newline at end of file diff --git a/ail_vru_uc1_scenario/cdasim_config/route_config/vru_uc1_north.csv b/ail_vru_uc1_scenario/cdasim_config/route_config/vru_uc1_north.csv new file mode 100755 index 00000000..13ee8b7b --- /dev/null +++ b/ail_vru_uc1_scenario/cdasim_config/route_config/vru_uc1_north.csv @@ -0,0 +1,2 @@ +0.002321,0.0019849,0,DEST_1 +0.0026284,0.0022296,0,vru_uc1_north diff --git a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py index 5f1c18d0..44c6412d 100644 --- a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py +++ b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py @@ -40,8 +40,8 @@ Configurations """ -WALKING_PERSON_SPEED_IN_MS = 1.0 -WALKING_PERSON_TRIGGER_WALKING_DISTANCE_IN_METERS = 11.0 +WALKING_PERSON_SPEED_IN_MS = 2.0 +WALKING_PERSON_TRIGGER_WALKING_DISTANCE_IN_METERS = 15.0 class VulnerableRoadUserCollision(BasicScenario): def __init__( diff --git a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml index 80921c39..7bf3241c 100644 --- a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml +++ b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml @@ -17,13 +17,13 @@ limitations under the License. --> - + - + diff --git a/ail_vru_uc1_scenario/cdasim_config/start_simulation b/ail_vru_uc1_scenario/cdasim_config/start_simulation new file mode 100755 index 00000000..84877b87 --- /dev/null +++ b/ail_vru_uc1_scenario/cdasim_config/start_simulation @@ -0,0 +1,15 @@ +#!/bin/bash +# Script to start simulation +# Launches RViz +# Prunes all previous Kafka volumes +carma stop all + +export ROS_MASTER_URI=http://172.3.0.2:11311/ + +bash -c 'sleep 35 && rviz -d ~/carma_ws/src/carma-platform/carma/rviz/carma_default.rviz' & + +docker volume rm \ + carma_kafka-datavolume \ + carma_zookeeper-datavolume + +carma start all \ No newline at end of file diff --git a/ail_vru_uc1_scenario/cdasim_config/stop_simulation b/ail_vru_uc1_scenario/cdasim_config/stop_simulation new file mode 100755 index 00000000..828492e4 --- /dev/null +++ b/ail_vru_uc1_scenario/cdasim_config/stop_simulation @@ -0,0 +1,21 @@ +#!/bin/bash +# Script to stop simulation. +# Pulls all Kafka message data +# Stops and removes all docker containers +# Prunes all Kafka related volumes +if ! [ -f /opt/carma-streets/scripts/collect_kafka_logs.py ] ; then + echo "Installing collect_kafka_logs.py into /opt/carma-streets/scripts/ ...." + wget -q https://raw.githubusercontent.com/usdot-fhwa-stol/carma-streets/release/lavida/collect_kafka_logs.py -P /opt/carma-streets/scripts +fi +filename=carma_streets_kafka_"$(date +%F_%H-%M-%S)" +echo "Collecting CARMA Streets Kafka messages into ${filename}.zip" +python3 /opt/carma-streets/scripts/collect_kafka_logs.py --zip True "${filename}" +echo "Stopping simulation ..." +carma stop all +# Kafka message volumes retain messages and consumer offsets from previous run +# Clearing volumes avoids consumer offsets and messages from previous runs impacting +# current scenario preformance. +echo "Clearing CARMA Streets Kafka message volumes ..." +docker volume rm \ + carma_kafka-datavolume \ + carma_zookeeper-datavolume \ No newline at end of file diff --git a/ail_vru_uc1_scenario/docker-compose.yml b/ail_vru_uc1_scenario/docker-compose.yml index 91261fce..fe116854 100644 --- a/ail_vru_uc1_scenario/docker-compose.yml +++ b/ail_vru_uc1_scenario/docker-compose.yml @@ -123,9 +123,12 @@ services: volumes_from: - container:carma-config:ro environment: - - ROS_IP=172.3.0.6 - - ROS_MASTER_URI=http://172.3.0.2:11311/ - - PYTHONUNBUFFERED=1 + ROS_IP: 172.3.0.6 + ROS_MASTER_URI: http://172.3.0.2:11311/ + PYTHONUNBUFFERED: 1 + VEHICLE_SELECTED_ROUTE: ${VEHICLE_SELECTED_ROUTE} + VEHICLE_SPAWN_POINT: ${VEHICLE_SPAWN_POINT} + # sleep is for carla simulator to become available # start_delay_in_seconds is carla game time seconds to adjust when to engage for the scenario # and account for delay required for world model to fully update after route is selected @@ -138,9 +141,9 @@ services: && roslaunch carma_carla_agent carma_carla_agent.launch role_name:='carma_1' host:='172.2.0.2' - selected_route:='trb2024_left_turn' + selected_route:=${VEHICLE_SELECTED_ROUTE} start_delay_in_seconds:='35' - spawn_point:='215.21,-169.32,0,0,0,0'" + spawn_point:=${VEHICLE_SPAWN_POINT}" ns3_adapter_1: image: usdotfhwastolcandidate/carma-ns3-adapter:lavida @@ -402,6 +405,8 @@ services: - carma_sim_net depends_on: - carma-simulation + environment: + SIMULATION_SCENARIO: ${SIMULATION_SCENARIO} volumes: - ./scenario-runner/vru_collision.py:/app/scenario_runner/srunner/scenarios/vru_collision.py - ./scenario-runner/vru_collision.xml:/app/scenario_runner/srunner/examples/vru_collision.xml @@ -411,7 +416,7 @@ services: entrypoint: > bash -c "sleep 30 && python3 scenario_runner.py - --scenario VulnerableRoadUserCollision_LeftTurn + --scenario ${SIMULATION_SCENARIO} --record metrics/data/ --host 172.2.0.2" diff --git a/ail_vru_uc1_scenario/docs/scenario_diagram.png b/ail_vru_uc1_scenario/docs/scenario_diagram.png deleted file mode 100644 index 5a812a55..00000000 Binary files a/ail_vru_uc1_scenario/docs/scenario_diagram.png and /dev/null differ diff --git a/ail_vru_uc1_scenario/docs/scenario_north.png b/ail_vru_uc1_scenario/docs/scenario_north.png new file mode 100644 index 00000000..9d74c73e Binary files /dev/null and b/ail_vru_uc1_scenario/docs/scenario_north.png differ diff --git a/ail_vru_uc1_scenario/docs/scenario_south.png b/ail_vru_uc1_scenario/docs/scenario_south.png new file mode 100644 index 00000000..ab607a72 Binary files /dev/null and b/ail_vru_uc1_scenario/docs/scenario_south.png differ