Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openscenario parameter assignment fix #834

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ed62a4a
Added __hash__ to ParameterRef to enable usage as dictionary key.
lasuomela Nov 9, 2021
18a3409
Moved UserDefinedAction parameter resolving into atomicbehaviours to …
lasuomela Nov 9, 2021
7aaa395
Updated to scenario_runner master
lasuomela Dec 21, 2021
5fae911
Wait for subrprocess completion in RunScript
lasuomela Dec 21, 2021
9287f95
Updated runscript fix
lasuomela Dec 21, 2021
1b50951
Merge branch 'carla-simulator:master' into openscenario_parameter_fix
lasuomela Dec 21, 2021
0813aa6
Moved ParameterRef resolution into runtime for AbsoluteTargetSpeed an…
lasuomela Dec 23, 2021
8039deb
OSC EnvironmentAction: Moved OSC parameter resolution to runtime
lasuomela Jan 3, 2022
5fce645
OSC TrafficSignalStateAction: moved parameter resolution to runtime
lasuomela Jan 4, 2022
521ab45
OSC CustomCommandAction: move parameter resolution to runtime
lasuomela Jan 4, 2022
6bdd347
OSC LongitudinalDistanceAction: moved parameter resolution to runtime
lasuomela Jan 4, 2022
0367b49
OSC LaneChangeAction: moved parameter resolution to runtime
lasuomela Jan 4, 2022
5239227
OSC LaneOffsetAction: moved parameter resolution to runtime
lasuomela Jan 5, 2022
744871f
OSC SynchronizeAction: moved parameter resolution to runtime
lasuomela Jan 6, 2022
9249b63
OSC ActivateControllerAction: move parameter resolution to runtime
lasuomela Jan 7, 2022
fa1ed9e
OSC ControllerAction: move parameter resolution to runtime
lasuomela Jan 7, 2022
b49ad0e
OSC RoutingAction: moved parameter resolution to runtime
lasuomela Jan 7, 2022
a306820
OSC EnvironmentAction: refactoring
lasuomela Jan 7, 2022
d0d7724
Code style improvements
lasuomela Jan 7, 2022
1b9906c
Update CHANGELOG.md
lasuomela Jan 7, 2022
5871fdc
Update openscenario_support.md
lasuomela Jan 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
### :bug: Bug Fixes
* Fixed bug at OtherLeadingVehicle scenario causing the vehicles to move faster than intended
* Fixed bug causing some debris at ControlLoss scenario to be floating, instead of at ground level
* Fixed bug causing OpenSCENARIO UserDefinedCommand subprocess runner to exit before executing script
* Fixed retrieval of OpenSCENARIO parameter values
* Fixed bug causing effects of OpenSCENARIO ParameterAction to be ignored in the execution of maneuvers

## CARLA ScenarioRunner 0.9.13
### :rocket: New Features
Expand Down
2 changes: 1 addition & 1 deletion Docs/openscenario_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contains of submodules, which are not listed, the support status applies to all
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| `EntityAction` | ❌ | ❌ | |
| `EnvironmentAction` | ✅ | ❌ | |
| `ParameterAction` | ✅ | ✅ | |
| `ParameterAction` | ✅ | ✅ | OSC Actions fully support ParameterActions. OSC conditions do not yet support ParameterAction: Changes to parameter values by ParameterAction aren't reflected in condition execution. |
| `InfrastructureAction` `TrafficSignalAction`<br>`TrafficAction` | &#10060; | &#10060; | |
| `InfrastructureAction` `TrafficSignalAction`<br>`TrafficSignalControllerAction` | &#10060; | &#10060; | |
| `InfrastructureAction` `TrafficSignalAction`<br>`TrafficSignalStateAction` | &#10060; | &#9989; | As traffic signals in CARLA towns have no unique ID, they have to be set by providing their position (Example: TrafficSignalStateAction name="pos=x,y" state="green"). The id can also be used for none CARLA town (Example: TrafficSignalStateAction name="id=n" state="green") |
Expand Down
32 changes: 17 additions & 15 deletions srunner/scenarioconfigs/openscenario_configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2021 Intel Corporation
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
Expand Down Expand Up @@ -98,7 +98,8 @@ def _check_version(self):
Ensure correct OpenSCENARIO version is used
"""
header = self.xml_tree.find("FileHeader")
if not (header.attrib.get('revMajor') == "1" and header.attrib.get('revMinor') == "0"):
if not (str(ParameterRef(header.attrib.get('revMajor'))) == "1" and
str(ParameterRef(header.attrib.get('revMinor'))) == "0"):
raise AttributeError("Only OpenSCENARIO 1.0 is supported")

def _load_catalogs(self):
Expand All @@ -124,7 +125,8 @@ def _load_catalogs(self):
if catalog is None:
continue

catalog_path = catalog.find("Directory").attrib.get('path') + "/" + catalog_type + "Catalog.xosc"
catalog_path = str(ParameterRef(catalog.find("Directory").attrib.get('path'))) + \
"/" + catalog_type + "Catalog.xosc"
if not os.path.isabs(catalog_path) and "xosc" in self.filename:
catalog_path = os.path.dirname(os.path.abspath(self.filename)) + "/" + catalog_path

Expand All @@ -134,17 +136,17 @@ def _load_catalogs(self):
xml_tree = ET.parse(catalog_path)
self._validate_openscenario_catalog_configuration(xml_tree)
catalog = xml_tree.find("Catalog")
catalog_name = catalog.attrib.get("name")
catalog_name = str(ParameterRef(catalog.attrib.get("name")))
self.catalogs[catalog_name] = {}
for entry in catalog:
self.catalogs[catalog_name][entry.attrib.get("name")] = entry
self.catalogs[catalog_name][str(ParameterRef(entry.attrib.get("name")))] = entry

def _set_scenario_name(self):
"""
Extract the scenario name from the OpenSCENARIO header information
"""
header = self.xml_tree.find("FileHeader")
self.name = header.attrib.get('description', 'Unknown')
self.name = str(ParameterRef(header.attrib.get('description', 'Unknown')))

if self.name.startswith("CARLA:"):
self.name = self.name[6:]
Expand All @@ -158,7 +160,7 @@ def _set_carla_town(self):
Hence, there can be multiple towns specified. We just use the _last_ one.
"""
for logic in self.xml_tree.find("RoadNetwork").findall("LogicFile"):
self.town = logic.attrib.get('filepath', None)
self.town = str(ParameterRef(logic.attrib.get('filepath', None)))

if self.town is not None and ".xodr" in self.town:
if not os.path.isabs(self.town):
Expand Down Expand Up @@ -235,7 +237,7 @@ def _set_actor_information(self):
"""
for entity in self.xml_tree.iter("Entities"):
for obj in entity.iter("ScenarioObject"):
rolename = obj.attrib.get('name', 'simulation')
rolename = str(ParameterRef(obj.attrib.get('name', 'simulation')))
args = {}
for prop in obj.iter("Property"):
key = prop.get('name')
Expand Down Expand Up @@ -290,8 +292,8 @@ def _extract_vehicle_information(self, obj, rolename, vehicle, args):
Helper function to _set_actor_information for getting vehicle information from XML tree
"""
color = None
model = vehicle.attrib.get('name', "vehicle.*")
category = vehicle.attrib.get('vehicleCategory', "car")
model = str(ParameterRef(vehicle.attrib.get('name', "vehicle.*")))
category = str(ParameterRef(vehicle.attrib.get('vehicleCategory', "car")))
ego_vehicle = False
for prop in obj.iter("Property"):
if prop.get('name', '') == 'type':
Expand All @@ -312,7 +314,7 @@ def _extract_pedestrian_information(self, obj, rolename, pedestrian, args):
"""
Helper function to _set_actor_information for getting pedestrian information from XML tree
"""
model = pedestrian.attrib.get('model', "walker.*")
model = str(ParameterRef(pedestrian.attrib.get('model', "walker.*")))

speed = self._get_actor_speed(rolename)
new_actor = ActorConfigurationData(model, None, rolename, speed, category="pedestrian", args=args)
Expand All @@ -323,13 +325,13 @@ def _extract_misc_information(self, obj, rolename, misc, args):
"""
Helper function to _set_actor_information for getting vehicle information from XML tree
"""
category = misc.attrib.get('miscObjectCategory')
category = str(ParameterRef(misc.attrib.get('miscObjectCategory')))
if category == "barrier":
model = "static.prop.streetbarrier"
elif category == "guardRail":
model = "static.prop.chainbarrier"
else:
model = misc.attrib.get('name')
model = str(ParameterRef(misc.attrib.get('name')))
new_actor = ActorConfigurationData(model, None, rolename, category="misc", args=args)

self.other_actors.append(new_actor)
Expand All @@ -351,7 +353,7 @@ def _get_actor_transform(self, actor_name):
actor_found = False

for private_action in self.init.iter("Private"):
if private_action.attrib.get('entityRef', None) == actor_name:
if str(ParameterRef(private_action.attrib.get('entityRef', None))) == actor_name:
if actor_found:
# pylint: disable=line-too-long
self.logger.warning(
Expand Down Expand Up @@ -380,7 +382,7 @@ def _get_actor_speed(self, actor_name):
actor_found = False

for private_action in self.init.iter("Private"):
if private_action.attrib.get('entityRef', None) == actor_name:
if str(ParameterRef(private_action.attrib.get('entityRef', None))) == actor_name:
if actor_found:
# pylint: disable=line-too-long
self.logger.warning(
Expand Down
Loading