Skip to content

Commit

Permalink
Add right turn scenario for VRU collision (#313)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
## Description

<!--- Describe your changes in detail -->
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: usdot-fhwa-stol/scenario-runner#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
<!--- 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
VRU use case verification testing
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
Sim PC 1
<!--- 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: -->

- [ ] 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! -->

- [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.
  • Loading branch information
MishkaMN committed Feb 7, 2024
1 parent 4d2471c commit 389cea1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>

<!--
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<scenarios>
<scenario name="VulnerableRoadUserCollision_LeftTurn" 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">
<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"/>
</scenario>
</scenarios>
5 changes: 3 additions & 2 deletions ail_vru_uc1_scenario/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 389cea1

Please sign in to comment.