From 389cea1092703a30ff1d9bbeb555e3c2a8a499d9 Mon Sep 17 00:00:00 2001 From: Misheel Bayartsengel Date: Wed, 7 Feb 2024 12:53:42 -0500 Subject: [PATCH] Add right turn scenario for VRU collision (#313) # PR Details ## Description As we get closer to verification testing, we need a scenario where permissive right turn results in vru collision. This scenario is described in Intersection Safety Challenge project. XML file addition that has the pedestriand and roadside equipment configuration is in this PR: https://github.com/usdot-fhwa-stol/scenario-runner/pull/3 The tester still only need to modify the Python file to change the pedestrian's speed and its trigger distance from the vehicle to start walking. ## Related Issue CDAR-731 https://usdot-carma.atlassian.net/browse/CDAR-731 ## Motivation and Context VRU use case verification testing ## How Has This Been Tested? Sim PC 1 ## Types of changes - [ ] 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: - [X] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [X] I have updated the documentation accordingly. - [X] I have read the **CONTRIBUTING** document. [CDA Telematics Contributing Guide](https://github.com/usdot-fhwa-stol/cda-telematics/blob/main/Contributing.md) - [X] I have added tests to cover my changes. - [X] All new and existing tests passed. --- .../{trb_2024.py => vru_collision.py} | 24 +++++++------- .../scenario-runner/vru_collision.xml | 31 +++++++++++++++++++ ail_vru_uc1_scenario/docker-compose.yml | 5 +-- 3 files changed, 45 insertions(+), 15 deletions(-) rename ail_vru_uc1_scenario/cdasim_config/scenario-runner/{trb_2024.py => vru_collision.py} (90%) create mode 100644 ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml diff --git a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/trb_2024.py b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py similarity index 90% rename from ail_vru_uc1_scenario/cdasim_config/scenario-runner/trb_2024.py rename to ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py index 918f7415..a8b4f50b 100644 --- a/ail_vru_uc1_scenario/cdasim_config/scenario-runner/trb_2024.py +++ b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.py @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Leidos +# Copyright 2024 Leidos # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,10 +37,10 @@ Configurations """ -WALKING_PERSON_SPEED_IN_MS = 1.34 -WALKING_PERSON_TRIGGER_WALKING_DISTANCE_IN_METERS = 20.0 +WALKING_PERSON_SPEED_IN_MS = 1.0 +WALKING_PERSON_TRIGGER_WALKING_DISTANCE_IN_METERS = 11.0 -class Trb2024(BasicScenario): +class VulnerableRoadUserCollision(BasicScenario): def __init__( self, world, @@ -67,8 +67,8 @@ def __init__( # references is in its __init__() function. self.timeout = timeout - super(Trb2024, self).__init__( - "Trb2024", + super(VulnerableRoadUserCollision, self).__init__( + "VulnerableRoadUserCollision", ego_vehicles, config, world, @@ -82,12 +82,11 @@ def __init__( spectator = world.get_spectator() spectator.set_transform( carla.Transform( - carla.Location(266.4068, -160.1683, 16.2939), - carla.Rotation(-34.0360, -126.9920, 0.0), + carla.Location(265.4068, -160.1683, 21.2939), + carla.Rotation(-60.0360, -126.9920, 0.0), ) ) - # self.carma_vehicle = ego_vehicles[0] self.other_actors_dict = {} def _initialize_actors(self, config: ScenarioConfiguration) -> None: @@ -149,13 +148,13 @@ def _create_behavior(self): CarlaDataProvider.register_actor(actor) crossing_person = self.other_actors_dict["crossing_person"] - # start_condition = Idle(5, name="start_condition") + start_condition = Idle(5, name="start_condition") start_condition = InTriggerDistanceToVehicle( crossing_person, carma_vehicle, WALKING_PERSON_TRIGGER_WALKING_DISTANCE_IN_METERS ) walk_across_street = KeepVelocity( - crossing_person, WALKING_PERSON_SPEED_IN_MS, 10.0, name="walk_across_street" + crossing_person, WALKING_PERSON_SPEED_IN_MS, 100.0, name="walk_across_street" ) dao = GlobalRoutePlannerDAO(CarlaDataProvider.get_map(), 2) @@ -164,9 +163,8 @@ def _create_behavior(self): actor_behaviors = py_trees.composites.Parallel(name="actor_behaviors") actor_behaviors.add_child(walk_across_street) - # actor_behaviors.add_child(drive_through_intersection) - end_condition = DriveDistance(carma_vehicle, 10) + end_condition = DriveDistance(carma_vehicle, 100) root = py_trees.composites.Sequence(name="root_sequence") root.add_child(start_condition) 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 new file mode 100644 index 00000000..80921c39 --- /dev/null +++ b/ail_vru_uc1_scenario/cdasim_config/scenario-runner/vru_collision.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + diff --git a/ail_vru_uc1_scenario/docker-compose.yml b/ail_vru_uc1_scenario/docker-compose.yml index 66cb8dbb..db9dda42 100644 --- a/ail_vru_uc1_scenario/docker-compose.yml +++ b/ail_vru_uc1_scenario/docker-compose.yml @@ -399,14 +399,15 @@ services: depends_on: - carma-simulation volumes: - - ./scenario-runner/trb_2024.py:/app/scenario_runner/srunner/scenarios/trb_2024.py + - ./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 - ./carla-recorder/:/app/scenario_runner/metrics/data/ # sleep is for mainly carma-platform's components to # activate and be ready before scenario starts entrypoint: > bash -c "sleep 30 && python3 scenario_runner.py - --scenario Trb2024_1 + --scenario VulnerableRoadUserCollision_LeftTurn --record metrics/data/ --host 172.2.0.2"