Skip to content

Commit

Permalink
CDAR-593: Update to route configuration and naming (#328)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
## Description
CARMA Config changes to scenario names. Also added docker environment
variables for scenario name and vehicle spawn point. Added
stop_simulation script that pulls kafka logs before stopping simulation
<!--- Describe your changes in detail -->

## Related Issue
CDAR-593
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
Scenario configuration for verification testing
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
XIL Cloud deployment 
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Defect fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
[CARMA Contributing
Guide](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md)
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

Tracking:
@MishkaMN
  • Loading branch information
paulbourelly999 authored Mar 19, 2024
1 parent e9c33a4 commit 98f3cf9
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 16 deletions.
16 changes: 11 additions & 5 deletions ail_vru_uc1_scenario/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 <carma-config-image-name>`
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.

Expand Down
15 changes: 14 additions & 1 deletion ail_vru_uc1_scenario/cdasim_config/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
INFRASTRUCTURE_ID=rsu_1234
SIMULATION_MODE=true
TIME_SYNC_TOPIC=time_sync
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.002321,0.0019849,0,DEST_1
0.0026284,0.0022296,0,vru_uc1_north
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ limitations under the License.
-->

<scenarios>
<scenario name="VulnerableRoadUserCollision_LeftTurn" type="VulnerableRoadUserCollision" town="Town04">
<scenario name="VulnerableRoadUserCollision_ThreeTrucks" type="VulnerableRoadUserCollision" town="Town04">
<other_actor x="250.38" y="-179.00" z="1.0" model="walker.pedestrian.0002" rolename="crossing_person"/>
<other_actor x="239.82" y="-173.39" z="0.2" yaw="180.0" model="vehicle.carlamotors.carlacola" rolename="heavy_vehicle_1"/>
<other_actor x="245.82" y="-173.39" z="0.2" yaw="180.0" model="vehicle.carlamotors.carlacola" rolename="heavy_vehicle_2"/>
<other_actor x="251.82" y="-175.00" z="0.2" yaw="145.0" model="vehicle.carlamotors.carlacola" rolename="heavy_vehicle_3"/>
</scenario>
<scenario name="VulnerableRoadUserCollision_RightTurn" type="VulnerableRoadUserCollision" town="Town04">
<scenario name="VulnerableRoadUserCollision_TrafficSign" type="VulnerableRoadUserCollision" town="Town04">
<other_actor x="250.38" y="-164.0" z="0.0" yaw="180.0" model="static.prop.trafficwarning" rolename="traffic_sign"/>
<other_actor x="250.38" y="-164.0" z="0.5" yaw="180.0" model="static.prop.streetbarrier" rolename="streetbarrier"/>
<other_actor x="250.30" y="-159.8" z="1.0" yaw="0.0" model="walker.pedestrian.0002" rolename="crossing_person"/>
Expand Down
15 changes: 15 additions & 0 deletions ail_vru_uc1_scenario/cdasim_config/start_simulation
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions ail_vru_uc1_scenario/cdasim_config/stop_simulation
Original file line number Diff line number Diff line change
@@ -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
17 changes: 11 additions & 6 deletions ail_vru_uc1_scenario/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
Binary file removed ail_vru_uc1_scenario/docs/scenario_diagram.png
Binary file not shown.
Binary file added ail_vru_uc1_scenario/docs/scenario_north.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ail_vru_uc1_scenario/docs/scenario_south.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98f3cf9

Please sign in to comment.