From 4aff6b4c7d391934673e84ba029577a2329123cb Mon Sep 17 00:00:00 2001 From: Weiss David Date: Mon, 2 Aug 2021 13:55:51 +0200 Subject: [PATCH 1/2] feat(Slave): Read TrafficRules from configs and allow reading them through WorldInterface Signed-off-by: Weiss David --- .../sim_user_guide/input/profilescatalog.rst | 33 +++++++++++++- .../sim_user_guide/input/slaveconfig.rst | 1 + .../ProfilesCatalog.xml | 43 ++++++++++++------- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 25 ++++++++++- .../slaveConfig.xml | 3 +- .../Configurations/AEB/ProfilesCatalog.xml | 25 ++++++++++- .../Configurations/AEB/slaveConfig.xml | 3 +- .../AFDM_TJunction/slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../LocalizationOnJunction/slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../OSCAction_RemoveAgent/ProfilesCatalog.xml | 25 ++++++++++- .../OSCAction_RemoveAgent/slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../ProfilesCatalog.xml | 29 +++++++++++-- .../slaveConfig.xml | 3 +- .../Pedestrian_Trajectory/ProfilesCatalog.xml | 25 ++++++++++- .../Sensor_Latency/ProfilesCatalog.xml | 25 ++++++++++- .../Sensor_Latency/slaveConfig.xml | 3 +- .../StaticAgentCollision/ProfilesCatalog.xml | 25 ++++++++++- .../Configurations/TrafficJam/slaveConfig.xml | 3 +- .../DefaultConfigurations/ProfilesCatalog.xml | 25 ++++++++++- .../DefaultConfigurations/slaveConfig.xml | 5 ++- sim/include/slaveConfigInterface.h | 1 + sim/include/worldInterface.h | 7 ++- sim/src/common/globalDefinitions.h | 42 +++--------------- sim/src/core/slave/bindings/world.h | 11 +++-- .../core/slave/framework/runInstantiator.cpp | 27 +++++++----- .../core/slave/framework/runInstantiator.h | 4 +- .../slave/importer/importerLoggingHelper.h | 1 + .../core/slave/importer/profilesImporter.h | 2 +- .../slave/importer/slaveConfigImporter.cpp | 4 ++ .../core/slave/importer/slaveConfigImporter.h | 2 +- .../modules/World_OSI/WorldImplementation.cpp | 26 +++++++++++ .../modules/World_OSI/WorldImplementation.h | 6 +-- sim/tests/fakes/gmock/fakeWorld.h | 2 +- .../invalidSpawnPointSlaveConfig.xml | 3 +- .../validSpawnPointSlaveConfig.xml | 3 +- .../core/slave/slaveConfigImporter_Tests.cpp | 2 + 61 files changed, 688 insertions(+), 152 deletions(-) mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_RemoveAgent/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/slaveConfig.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml mode change 100755 => 100644 sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/slaveConfig.xml diff --git a/doc/source/user_guide/sim_user_guide/input/profilescatalog.rst b/doc/source/user_guide/sim_user_guide/input/profilescatalog.rst index 36e933fc..450501c7 100644 --- a/doc/source/user_guide/sim_user_guide/input/profilescatalog.rst +++ b/doc/source/user_guide/sim_user_guide/input/profilescatalog.rst @@ -15,7 +15,7 @@ ProfilesCatalog =============== The ProfilesCatalog contains all AgentProfiles, VehicleProfiles and generic ProfileGroups and Profiles. -Depending on the configuration the simulator could require a "Driver"-ProfileGroup, a "Spawner"- and "TrafficGroup"-ProfileGroup, or sensor and vehiclecomponent specific ProfileGroups. +Depending on the configuration the simulator could require a "Driver"-ProfileGroup, a "Spawner"- and "TrafficGroup"-ProfileGroup, a "TrafficRules"-ProfileGroup or sensor and vehiclecomponent specific ProfileGroups. * :ref:`profilescatalog_agentprofiles` * :ref:`profilescatalog_vehicleprofiles` @@ -23,6 +23,7 @@ Depending on the configuration the simulator could require a "Driver"-ProfileGro * :ref:`profilescatalog_driverprofiles` * :ref:`profilescatalog_vehiclecomponentprofiles` * :ref:`profilescatalog_spawnerprofiles` +* :ref:`profilescatalog_trafficrulesprofiles` .. _profilescatalog_agentprofiles: @@ -303,3 +304,33 @@ For details on the indivual parameters see the :ref:`components reference ... + + +.. _profilescatalog_trafficrulesprofiles: + +TrafficRules ProfileGroup +------------------------- + +This sections contains the global traffic rules, that may vary depending on the country. +The :ref:`slaveconfig_environment` section in the SlaveConfig defines which set is used. +Currently there are only rules regulating highway traffic. These are the following: + ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ +| Name | Type | Description | ++===========================+=========+=====================================================================================================================+ +| OpenSpeedLimit | Double | maximum allowed speed if not restricted by signs | ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ +| KeepToOuterLanes | Bool | if true, vehicles must use the outermost free lane for driving | ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ +| DontOvertakeOnOuterLanes | Bool | if true, it is prohibited to overtake another vehicle, that is driving further left (or right for lefthand traffic) | ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ +| FormRescueLane | Bool | if true, vehicles driving in a traffic jam must form a corridor for emergency vehicles | ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ +| ZipperMerge | Bool | if true all merging shall be performed using zipper merge | ++---------------------------+---------+---------------------------------------------------------------------------------------------------------------------+ + +.. literalinclude:: @OP_REL_SIM@/contrib/examples/Common/ProfilesCatalog.xml + :language: xml + :start-at: + :end-at: + diff --git a/doc/source/user_guide/sim_user_guide/input/slaveconfig.rst b/doc/source/user_guide/sim_user_guide/input/slaveconfig.rst index 350b7f44..20720c48 100644 --- a/doc/source/user_guide/sim_user_guide/input/slaveconfig.rst +++ b/doc/source/user_guide/sim_user_guide/input/slaveconfig.rst @@ -112,6 +112,7 @@ All probabilities need to add up to 1.0. VisibilityDistance Defines how far a human driver can see [m]. 1+ entry Friction Friction on the road. Used by DynamicsRegularDriving and LimiterAccelerationVehicleComponents. 1+ entry Weather **Currently unused.** Weather as string 1+ entry + TrafficRules Defines which set of TrafficRules to use from the ProfilesCatalog yes =================== ============================================================================================== ========= **Example** diff --git a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/ProfilesCatalog.xml index 83d7638a..b6975149 100644 --- a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -32,13 +32,7 @@ - + @@ -73,7 +67,7 @@ - + @@ -86,13 +80,32 @@ - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/slaveConfig.xml b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/slaveConfig.xml index 138e19c9..12e23d24 100644 --- a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacle/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/ProfilesCatalog.xml index d11e653f..51d217df 100644 --- a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -283,4 +283,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/slaveConfig.xml b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/slaveConfig.xml index 31cb4d8d..7e0dba06 100644 --- a/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ADAS_AEB_PreventingCollisionWithObstacleInCurve/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 0 @@ -27,6 +27,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/AEB/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/AEB/ProfilesCatalog.xml index c9b5770d..79714bc1 100644 --- a/sim/contrib/examples/Configurations/AEB/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/AEB/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -232,4 +232,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/AEB/slaveConfig.xml b/sim/contrib/examples/Configurations/AEB/slaveConfig.xml index 71ad49c8..5134c9e0 100644 --- a/sim/contrib/examples/Configurations/AEB/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/AEB/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 0 @@ -27,6 +27,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/AFDM_TJunction/slaveConfig.xml b/sim/contrib/examples/Configurations/AFDM_TJunction/slaveConfig.xml index 3e6a9491..af975cad 100644 --- a/sim/contrib/examples/Configurations/AFDM_TJunction/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/AFDM_TJunction/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/ProfilesCatalog.xml old mode 100755 new mode 100644 index 04d9a95f..3671d0d8 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -35,7 +35,7 @@ - + @@ -59,10 +59,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/slaveConfig.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeLane/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/ProfilesCatalog.xml old mode 100755 new mode 100644 index ec86059d..1c3b9230 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -35,7 +35,7 @@ - + @@ -59,10 +59,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/slaveConfig.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RelativeSpeed/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/slaveConfig.xml b/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_RoadPosition/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/ProfilesCatalog.xml old mode 100755 new mode 100644 index 04d9a95f..3671d0d8 --- a/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -35,7 +35,7 @@ - + @@ -59,10 +59,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/slaveConfig.xml b/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_TimeHeadway/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/ProfilesCatalog.xml old mode 100755 new mode 100644 index 04d9a95f..3671d0d8 --- a/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -35,7 +35,7 @@ - + @@ -59,10 +59,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/slaveConfig.xml b/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/ByEntityCondition_TimeToCollision/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/LocalizationOnJunction/slaveConfig.xml b/sim/contrib/examples/Configurations/LocalizationOnJunction/slaveConfig.xml index 323acf6a..4ff86d2b 100644 --- a/sim/contrib/examples/Configurations/LocalizationOnJunction/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/LocalizationOnJunction/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Absolute/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeLeft_Relative/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Absolute/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_DoubleSinusoidalLaneChangeRight_Relative/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/ProfilesCatalog.xml index eec8b435..1a9b50c6 100644 --- a/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -23,4 +23,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_RemoveAgent/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Absolute/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeLeft_Relative/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Absolute/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml old mode 100755 new mode 100644 index c9199aab..d25a6b20 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + @@ -35,10 +35,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/slaveConfig.xml b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/slaveConfig.xml old mode 100755 new mode 100644 index 6b64508d..1741fa40 --- a/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/OSCAction_SinusoidalLaneChangeRight_Relative/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml index 9b0bc981..b4157df2 100644 --- a/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -194,4 +194,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/Sensor_Latency/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/Sensor_Latency/ProfilesCatalog.xml index 22216c83..9b9ad1b0 100644 --- a/sim/contrib/examples/Configurations/Sensor_Latency/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/Sensor_Latency/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -57,4 +57,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/Sensor_Latency/slaveConfig.xml b/sim/contrib/examples/Configurations/Sensor_Latency/slaveConfig.xml index 7e9569c3..5bdac092 100644 --- a/sim/contrib/examples/Configurations/Sensor_Latency/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/Sensor_Latency/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -27,6 +27,7 @@ + Germany diff --git a/sim/contrib/examples/Configurations/StaticAgentCollision/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/StaticAgentCollision/ProfilesCatalog.xml index 95610e9b..d43e6f5c 100644 --- a/sim/contrib/examples/Configurations/StaticAgentCollision/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/StaticAgentCollision/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -157,4 +157,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/TrafficJam/slaveConfig.xml b/sim/contrib/examples/Configurations/TrafficJam/slaveConfig.xml index 4e4904eb..e4c076cb 100644 --- a/sim/contrib/examples/Configurations/TrafficJam/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/TrafficJam/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -24,6 +24,7 @@ + Germany diff --git a/sim/contrib/examples/DefaultConfigurations/ProfilesCatalog.xml b/sim/contrib/examples/DefaultConfigurations/ProfilesCatalog.xml index 2f940c91..fc8541df 100644 --- a/sim/contrib/examples/DefaultConfigurations/ProfilesCatalog.xml +++ b/sim/contrib/examples/DefaultConfigurations/ProfilesCatalog.xml @@ -1,4 +1,4 @@ - + @@ -181,4 +181,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sim/contrib/examples/DefaultConfigurations/slaveConfig.xml b/sim/contrib/examples/DefaultConfigurations/slaveConfig.xml index 26573cd1..9c188079 100644 --- a/sim/contrib/examples/DefaultConfigurations/slaveConfig.xml +++ b/sim/contrib/examples/DefaultConfigurations/slaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 123 @@ -27,6 +27,7 @@ + Germany @@ -77,4 +78,4 @@ DefaultRuntimeCommon - \ No newline at end of file + diff --git a/sim/include/slaveConfigInterface.h b/sim/include/slaveConfigInterface.h index 062b90a1..04bfefb1 100644 --- a/sim/include/slaveConfigInterface.h +++ b/sim/include/slaveConfigInterface.h @@ -50,6 +50,7 @@ struct EnvironmentConfig IntProbabilities visibilityDistances {}; DoubleProbabilities frictions {}; StringProbabilities weathers {}; + std::string trafficRules {}; }; //----------------------------------------------------------------------------- diff --git a/sim/include/worldInterface.h b/sim/include/worldInterface.h index b09a96b3..0e10e041 100644 --- a/sim/include/worldInterface.h +++ b/sim/include/worldInterface.h @@ -119,12 +119,11 @@ public: virtual double GetVisibilityDistance() const = 0; //----------------------------------------------------------------------------- - //! Sets the world parameters like weekday, library - //! @param[in] worldParamter parameter to setup world + //! Retrieves traffic rules //! - //! @return + //! @return traffic rules //----------------------------------------------------------------------------- - virtual void SetParameter(WorldParameter *worldParameter) = 0; + virtual const TrafficRules& GetTrafficRules() const = 0; //----------------------------------------------------------------------------- //! Sets the world parameters like weekday, library diff --git a/sim/src/common/globalDefinitions.h b/sim/src/common/globalDefinitions.h index 60b1b7ab..4592e88b 100644 --- a/sim/src/common/globalDefinitions.h +++ b/sim/src/common/globalDefinitions.h @@ -368,42 +368,14 @@ enum class LaneCategory RightMostLane }; -class WorldParameter +//! Defines which traffic rules are in effect +struct TrafficRules { -public: - WorldParameter(Weekday weekday, - int timeOfDay, - const std::string &libraryName) : - weekday(weekday), - timeOfDay(timeOfDay), - libraryName(libraryName) - { - } - WorldParameter(const WorldParameter &) = delete; - WorldParameter(WorldParameter &&) = delete; - WorldParameter &operator=(const WorldParameter &) = delete; - WorldParameter &operator=(WorldParameter &&) = delete; - virtual ~WorldParameter() = default; - - Weekday GetWeekday() - { - return weekday; - } - - int GetTimeOfDay() - { - return timeOfDay; - } - - const std::string &GetLibraryName() const - { - return libraryName; - } - -private: - Weekday weekday; - int timeOfDay; - const std::string libraryName; + double openSpeedLimit; //!< maximum allowed speed if not restricted by signs + bool keepToOuterLanes; //!< if true, vehicles must use the outermost free lane for driving + bool dontOvertakeOnOuterLanes; //!< if true, it is prohibited to overtake another vehicle, that is driving further left (or right for lefthand traffic) + bool formRescueLane; //!< if true, vehicles driving in a traffic jam must form a corridor for emergency vehicles + bool zipperMerge; //!< if true all merging shall be performed using zipper merge }; //----------------------------------------------------------------------------- diff --git a/sim/src/core/slave/bindings/world.h b/sim/src/core/slave/bindings/world.h index 12a66cee..95d45d96 100644 --- a/sim/src/core/slave/bindings/world.h +++ b/sim/src/core/slave/bindings/world.h @@ -107,6 +107,11 @@ public: return implementation->GetVisibilityDistance(); } + const TrafficRules& GetTrafficRules() const override + { + return implementation->GetTrafficRules(); + } + double GetFriction() const override { return implementation->GetFriction(); @@ -278,8 +283,6 @@ public: //----------------------------------------------------------------------------- //! Instantiate the world by creating a WorldInterface out of a world library - //! with given world parameters - //! @param[in] worldParameter parameters of world inclusive library path //! //! @return true if successful //----------------------------------------------------------------------------- @@ -406,10 +409,6 @@ public: { return implementation->GetWeekday(); } - virtual void SetParameter(WorldParameter *worldParameter) override - { - return implementation->SetParameter(worldParameter); - } virtual bool CreateGlobalDrivingView() override { return implementation->CreateGlobalDrivingView(); diff --git a/sim/src/core/slave/framework/runInstantiator.cpp b/sim/src/core/slave/framework/runInstantiator.cpp index ba8f5c72..8a793de8 100644 --- a/sim/src/core/slave/framework/runInstantiator.cpp +++ b/sim/src/core/slave/framework/runInstantiator.cpp @@ -49,6 +49,7 @@ bool RunInstantiator::ExecuteRun() auto &scenario = *configurationContainer.GetScenario(); auto &scenery = *configurationContainer.GetScenery(); auto &slaveConfig = *configurationContainer.GetSlaveConfig(); + auto &profiles = *configurationContainer.GetProfiles(); auto &experimentConfig = slaveConfig.GetExperimentConfig(); auto &environmentConfig = slaveConfig.GetEnvironmentConfig(); @@ -72,7 +73,7 @@ bool RunInstantiator::ExecuteRun() LOG_INTERN(LogLevel::DebugCore) << std::endl << "### run number: " << invocation << " ###"; auto seed = static_cast(experimentConfig.randomSeed + invocation); - if (!InitRun(seed, environmentConfig, runResult)) + if (!InitRun(seed, environmentConfig, profiles, runResult)) { LOG_INTERN(LogLevel::DebugCore) << std::endl << "### run initialization failed ###"; @@ -152,23 +153,27 @@ void RunInstantiator::InitializeSpawnPointNetwork() "Failed to instantiate SpawnPointNetwork"); } -std::unique_ptr RunInstantiator::SampleWorldParameters(const EnvironmentConfig& environmentConfig, StochasticsInterface* stochastics, const openpass::common::RuntimeInformation& runtimeInformation) +std::unique_ptr RunInstantiator::SampleWorldParameters(const EnvironmentConfig& environmentConfig, const ProfileGroup& trafficRules, StochasticsInterface* stochastics, const openpass::common::RuntimeInformation& runtimeInformation) { - return openpass::parameter::make( - runtimeInformation, openpass::parameter::ParameterSetLevel1 { - { "TimeOfDay", Sampler::Sample(environmentConfig.timeOfDays, stochastics) }, - { "VisibilityDistance", Sampler::Sample(environmentConfig.visibilityDistances, stochastics) }, - { "Friction", Sampler::Sample(environmentConfig.frictions, stochastics) }, - { "Weather", Sampler::Sample(environmentConfig.weathers, stochastics) }} - ); + auto trafficRule = helper::map::query(trafficRules, environmentConfig.trafficRules); + ThrowIfFalse(trafficRule.has_value(), "No traffic rule set with name " + environmentConfig.trafficRules + " defined in ProfilesCatalog"); + auto parameters = trafficRule.value(); + parameters.emplace_back("TimeOfDay", Sampler::Sample(environmentConfig.timeOfDays, stochastics)); + parameters.emplace_back("VisibilityDistance", Sampler::Sample(environmentConfig.visibilityDistances, stochastics)); + parameters.emplace_back("Friction", Sampler::Sample(environmentConfig.frictions, stochastics)); + parameters.emplace_back("Weather", Sampler::Sample(environmentConfig.weathers, stochastics)); + + return openpass::parameter::make(runtimeInformation, parameters); } -bool RunInstantiator::InitRun(std::uint32_t seed, const EnvironmentConfig &environmentConfig, RunResult &runResult) +bool RunInstantiator::InitRun(std::uint32_t seed, const EnvironmentConfig &environmentConfig, ProfilesInterface& profiles, RunResult &runResult) { try { stochastics.InitGenerator(seed); - worldParameter = SampleWorldParameters(environmentConfig, &stochastics, configurationContainer.GetRuntimeInformation()); + auto trafficRules = helper::map::query(profiles.GetProfileGroups(), "TrafficRules"); + ThrowIfFalse(trafficRules.has_value(), "No traffic rules defined in ProfilesCatalog"); + worldParameter = SampleWorldParameters(environmentConfig, trafficRules.value(), &stochastics, configurationContainer.GetRuntimeInformation()); world.ExtractParameter(worldParameter.get()); observationNetwork.InitRun(); diff --git a/sim/src/core/slave/framework/runInstantiator.h b/sim/src/core/slave/framework/runInstantiator.h index 8416aed6..6aeea0eb 100644 --- a/sim/src/core/slave/framework/runInstantiator.h +++ b/sim/src/core/slave/framework/runInstantiator.h @@ -87,10 +87,10 @@ public: private: bool InitPreRun(ScenarioInterface& scenario, SceneryInterface& scenery); - bool InitRun(std::uint32_t seed, const EnvironmentConfig& environmentConfig, RunResult& runResult); + bool InitRun(std::uint32_t seed, const EnvironmentConfig& environmentConfig, ProfilesInterface &profiles, RunResult& runResult); void InitializeFrameworkModules(ScenarioInterface &scenario); void InitializeSpawnPointNetwork(); - std::unique_ptr SampleWorldParameters(const EnvironmentConfig& environmentConfig, StochasticsInterface* stochastics, const openpass::common::RuntimeInformation& runtimeInformation); + std::unique_ptr SampleWorldParameters(const EnvironmentConfig& environmentConfig, const ProfileGroup& trafficRules, StochasticsInterface* stochastics, const openpass::common::RuntimeInformation& runtimeInformation); void ClearRun(); diff --git a/sim/src/core/slave/importer/importerLoggingHelper.h b/sim/src/core/slave/importer/importerLoggingHelper.h index 6e8cd672..e3775ec0 100644 --- a/sim/src/core/slave/importer/importerLoggingHelper.h +++ b/sim/src/core/slave/importer/importerLoggingHelper.h @@ -446,6 +446,7 @@ namespace openpass::importer::xml::slaveConfigImporter::tag constexpr char spawners[] {"Spawners"}; constexpr char timeOfDay[] {"TimeOfDay"}; constexpr char timeOfDays[] {"TimeOfDays"}; + constexpr char trafficRules[] {"TrafficRules"}; constexpr char type[] {"Type"}; constexpr char visibilityDistance[] {"VisibilityDistance"}; constexpr char visibilityDistances[] {"VisibilityDistances"}; diff --git a/sim/src/core/slave/importer/profilesImporter.h b/sim/src/core/slave/importer/profilesImporter.h index d38cbfbf..fdd19005 100644 --- a/sim/src/core/slave/importer/profilesImporter.h +++ b/sim/src/core/slave/importer/profilesImporter.h @@ -114,7 +114,7 @@ public: private: static constexpr auto profilesCatalogFile = "ProfilesCatalog.xml"; - static constexpr auto supportedConfigVersion = "0.4.5"; + static constexpr auto supportedConfigVersion = "0.4.6"; }; } //namespace Importer diff --git a/sim/src/core/slave/importer/slaveConfigImporter.cpp b/sim/src/core/slave/importer/slaveConfigImporter.cpp index 8ae5b2f9..6fb4ae07 100644 --- a/sim/src/core/slave/importer/slaveConfigImporter.cpp +++ b/sim/src/core/slave/importer/slaveConfigImporter.cpp @@ -114,6 +114,10 @@ void SlaveConfigImporter::ImportEnvironment(QDomElement environmentElement, environmentElement, "Tag " + std::string(TAG::weathers) + " is missing."); ThrowIfFalse(ImportProbabilityMap(weathersElement, "Value", TAG::weather, environmentConfig.weathers, LogErrorAndThrow), weathersElement, "Could not import Probabilities."); + + //Parse traffic rules + ThrowIfFalse(ParseString(environmentElement, TAG::trafficRules, environmentConfig.trafficRules), + environmentElement, "Tag " + std::string(TAG::trafficRules) + " is missing."); } void SlaveConfigImporter::ImportSpawners(const QDomElement &spawnersElement, diff --git a/sim/src/core/slave/importer/slaveConfigImporter.h b/sim/src/core/slave/importer/slaveConfigImporter.h index d3adf912..e3d5c687 100644 --- a/sim/src/core/slave/importer/slaveConfigImporter.h +++ b/sim/src/core/slave/importer/slaveConfigImporter.h @@ -101,7 +101,7 @@ public: private: static std::string GetLibrary(const QDomElement& root, const std::string& key, const std::string& tag); - static constexpr auto supportedConfigVersion = "0.8.1"; + static constexpr auto supportedConfigVersion = "0.8.2"; //! \brief Identifier with correspondiong default values for mandatory libraries //! \note: The identifier is identical to the XML tag diff --git a/sim/src/core/slave/modules/World_OSI/WorldImplementation.cpp b/sim/src/core/slave/modules/World_OSI/WorldImplementation.cpp index 2eaff047..a3f64a7f 100644 --- a/sim/src/core/slave/modules/World_OSI/WorldImplementation.cpp +++ b/sim/src/core/slave/modules/World_OSI/WorldImplementation.cpp @@ -79,16 +79,42 @@ const std::vector& WorldImplementation::GetTraffi return trafficObjects; } +const TrafficRules& WorldImplementation::GetTrafficRules() const +{ + return worldParameter.trafficRules; +} + void WorldImplementation::ExtractParameter(ParameterInterface* parameters) { auto intParameter = parameters->GetParametersInt(); auto doubleParameter = parameters->GetParametersDouble(); auto stringParameter = parameters->GetParametersString(); + auto boolParameter = parameters->GetParametersBool(); worldParameter.timeOfDay = stringParameter.at("TimeOfDay"); worldParameter.visibilityDistance = intParameter.at("VisibilityDistance"); worldParameter.friction = doubleParameter.at("Friction"); worldParameter.weather = stringParameter.at("Weather"); + + auto openSpeedLimit = helper::map::query(doubleParameter, "OpenSpeedLimit"); + THROWIFFALSE(openSpeedLimit.has_value(), "Missing traffic rule OpenSpeedLimit") + worldParameter.trafficRules.openSpeedLimit = openSpeedLimit.value(); + + auto keepToOuterLanes = helper::map::query(boolParameter, "KeepToOuterLanes"); + THROWIFFALSE(keepToOuterLanes.has_value(), "Missing traffic rule KeepToOuterLanes") + worldParameter.trafficRules.keepToOuterLanes = keepToOuterLanes.value(); + + auto dontOvertakeOnOuterLanes = helper::map::query(boolParameter, "DontOvertakeOnOuterLanes"); + THROWIFFALSE(dontOvertakeOnOuterLanes.has_value(), "Missing traffic rule DontOvertakeOnOuterLanes") + worldParameter.trafficRules.dontOvertakeOnOuterLanes = dontOvertakeOnOuterLanes.value(); + + auto formRescueLane = helper::map::query(boolParameter, "FormRescueLane"); + THROWIFFALSE(formRescueLane.has_value(), "Missing traffic rule FormRescueLane") + worldParameter.trafficRules.formRescueLane = formRescueLane.value(); + + auto zipperMerge = helper::map::query(boolParameter, "ZipperMerge"); + THROWIFFALSE(zipperMerge.has_value(), "Missing traffic rule ZipperMerge") + worldParameter.trafficRules.zipperMerge = zipperMerge.value(); } void WorldImplementation::Reset() diff --git a/sim/src/core/slave/modules/World_OSI/WorldImplementation.h b/sim/src/core/slave/modules/World_OSI/WorldImplementation.h index d0d9d821..93c1172c 100644 --- a/sim/src/core/slave/modules/World_OSI/WorldImplementation.h +++ b/sim/src/core/slave/modules/World_OSI/WorldImplementation.h @@ -44,6 +44,7 @@ struct WorldParameterOSI int visibilityDistance {0}; double friction {0.0}; std::string weather {""}; + TrafficRules trafficRules{}; }; #include "osi3/osi_groundtruth.pb.h" @@ -113,6 +114,7 @@ public: const std::list GetRemovedAgentsInPreviousTimestep() override; const std::vector& GetTrafficObjects() const override; + const TrafficRules& GetTrafficRules() const override; // framework internal methods to access members without restrictions void ExtractParameter(ParameterInterface* parameters) override; @@ -249,10 +251,6 @@ public: { throw std::runtime_error("WorldImplementation::GetWeekday not implemented"); } - virtual void SetParameter([[maybe_unused]]WorldParameter *worldParameter) override - { - throw std::runtime_error("WorldImplementation::SetParameter not implemented"); - } virtual bool CreateGlobalDrivingView() override { throw std::runtime_error("WorldImplementation::CreateGlobalDrivingView not implemented"); diff --git a/sim/tests/fakes/gmock/fakeWorld.h b/sim/tests/fakes/gmock/fakeWorld.h index 8713af6a..35eea99b 100644 --- a/sim/tests/fakes/gmock/fakeWorld.h +++ b/sim/tests/fakes/gmock/fakeWorld.h @@ -67,6 +67,7 @@ class FakeWorld : public WorldInterface MOCK_CONST_METHOD6(GetObstruction, RouteQueryResult (const RoadGraph& roadGraph, RoadGraphVertex startNode, const GlobalRoadPosition& ownPosition, const ObjectPosition& otherPosition, const std::vector& objectCorner, const Common::Vector2d& mainLaneLocator)); MOCK_CONST_METHOD0(GetTimeOfDay, std::string()); + MOCK_CONST_METHOD0(GetTrafficRules, const TrafficRules& ()); MOCK_CONST_METHOD5(GetTrafficSignsInRange, RouteQueryResult>(const RoadGraph& roadGraph, RoadGraphVertex startNode, int laneId, double startDistance, double searchRange)); MOCK_CONST_METHOD5(GetRoadMarkingsInRange, RouteQueryResult>(const RoadGraph& roadGraph, RoadGraphVertex startNode, int laneId, double startDistance, double searchRange)); MOCK_CONST_METHOD5(GetTrafficLightsInRange, RouteQueryResult>(const RoadGraph& roadGraph, RoadGraphVertex startNode, int laneId, double startDistance, double searchRange)); @@ -85,7 +86,6 @@ class FakeWorld : public WorldInterface MOCK_METHOD1(QueueAgentUpdate, void(std::function func)); MOCK_METHOD2(QueueAgentUpdate, void(std::function func, double val)); MOCK_METHOD0(Reset, void()); - MOCK_METHOD1(SetParameter, void(WorldParameter *worldParameter)); MOCK_METHOD1(SetTimeOfDay, void(int timeOfDay)); MOCK_METHOD1(SetWeekday, void(Weekday weekday)); MOCK_METHOD1(SyncGlobalData, void(int timestamp)); diff --git a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/invalidSpawnPointSlaveConfig.xml b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/invalidSpawnPointSlaveConfig.xml index 33cd63c2..8739125e 100644 --- a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/invalidSpawnPointSlaveConfig.xml +++ b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/invalidSpawnPointSlaveConfig.xml @@ -1,5 +1,5 @@ - + ProfilesCatalog.xml 0 @@ -28,6 +28,7 @@ + Germany diff --git a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/validSpawnPointSlaveConfig.xml b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/validSpawnPointSlaveConfig.xml index 3dbc63b5..254b5220 100644 --- a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/validSpawnPointSlaveConfig.xml +++ b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/validSpawnPointSlaveConfig.xml @@ -1,4 +1,4 @@ - + ProfilesCatalog.xml 0 @@ -27,6 +27,7 @@ + Germany diff --git a/sim/tests/unitTests/core/slave/slaveConfigImporter_Tests.cpp b/sim/tests/unitTests/core/slave/slaveConfigImporter_Tests.cpp index 31ee18d4..5025fd65 100644 --- a/sim/tests/unitTests/core/slave/slaveConfigImporter_Tests.cpp +++ b/sim/tests/unitTests/core/slave/slaveConfigImporter_Tests.cpp @@ -292,6 +292,7 @@ TEST(SlaveConfigImporter_UnitTests, ImportEnvironmentConfigSuccessfully) "" "" "" + "Country" "" ); @@ -308,6 +309,7 @@ TEST(SlaveConfigImporter_UnitTests, ImportEnvironmentConfigSuccessfully) Pair(0.7, 0.5))); ASSERT_THAT(environmentConfig.weathers, ElementsAre(Pair("Rainy", 0.5), Pair("Snowy", 0.5))); + ASSERT_THAT(environmentConfig.trafficRules, Eq("Country")); } TEST(SlaveConfigImporter_UnitTests, ImportEnvironmentConfigUnsuccessfully) -- GitLab From 61779d060ad149d08244a5c6040127449f1e9e63 Mon Sep 17 00:00:00 2001 From: mscharfenberg Date: Fri, 17 Sep 2021 11:05:07 +0200 Subject: [PATCH 2/2] Update GUI config generation with new config element Trafficrules --- .../DataStructuresXml/XmlProfilesConfig.cpp | 26 ++++++++++++++++++- .../DataStructuresXml/XmlSlaveConfig.cpp | 1 + .../Configurations/PCM/ProfilesCatalog.xml | 10 ++++++- .../Configurations/PCM/slaveConfig.xml | 1 + 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlProfilesConfig.cpp b/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlProfilesConfig.cpp index fb7e9041..f4852bb7 100644 --- a/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlProfilesConfig.cpp +++ b/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlProfilesConfig.cpp @@ -89,8 +89,32 @@ bool XmlProfilesConfig::WriteToXml(QXmlStreamWriter *xmlWriter) xmlWriter->writeStartElement("ProfileGroup"); xmlWriter->writeAttribute("Type","Driver"); + xmlWriter->writeEndElement(); // ProfileGroup + + xmlWriter->writeStartElement("ProfileGroup"); + xmlWriter->writeAttribute("Type","TrafficRules"); xmlWriter->writeStartElement("Profile"); - xmlWriter->writeAttribute("Name","Regular"); + xmlWriter->writeAttribute("Name","Germany"); + xmlWriter->writeStartElement("Double"); + xmlWriter->writeAttribute("Key", "OpenSpeedLimit"); + xmlWriter->writeAttribute("Value", "infinity"); + xmlWriter->writeEndElement(); // Double + xmlWriter->writeStartElement("Bool"); + xmlWriter->writeAttribute("Key", "KeepToOuterLanes"); + xmlWriter->writeAttribute("Value", "true"); + xmlWriter->writeEndElement(); // Bool + xmlWriter->writeStartElement("Bool"); + xmlWriter->writeAttribute("Key", "DontOvertakeOnOuterLanes"); + xmlWriter->writeAttribute("Value", "true"); + xmlWriter->writeEndElement(); // Bool + xmlWriter->writeStartElement("Bool"); + xmlWriter->writeAttribute("Key", "FormRescueLane"); + xmlWriter->writeAttribute("Value", "true"); + xmlWriter->writeEndElement(); // Bool + xmlWriter->writeStartElement("Bool"); + xmlWriter->writeAttribute("Key", "ZipperMerge"); + xmlWriter->writeAttribute("Value", "true"); + xmlWriter->writeEndElement(); // Bool xmlWriter->writeEndElement(); // Profile xmlWriter->writeEndElement(); // ProfileGroup diff --git a/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlSlaveConfig.cpp b/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlSlaveConfig.cpp index 9531512f..de0e1e9e 100644 --- a/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlSlaveConfig.cpp +++ b/gui/plugins/pcmSimulation/Models/ConfigurationGeneratorPcm/DataStructuresXml/XmlSlaveConfig.cpp @@ -91,6 +91,7 @@ bool XmlSlaveConfig::WriteToXml(QXmlStreamWriter *xmlWriter) xmlWriter->writeAttribute("Value","Clear"); xmlWriter->writeEndElement(); // Weather xmlWriter->writeEndElement(); // Weathers + xmlWriter->writeTextElement("TrafficRules", "Germany"); xmlWriter->writeEndElement(); // Environment diff --git a/sim/contrib/examples/Configurations/PCM/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/PCM/ProfilesCatalog.xml index 7f003155..c99e3c64 100644 --- a/sim/contrib/examples/Configurations/PCM/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/PCM/ProfilesCatalog.xml @@ -18,6 +18,14 @@ - + + + + + + + + + diff --git a/sim/contrib/examples/Configurations/PCM/slaveConfig.xml b/sim/contrib/examples/Configurations/PCM/slaveConfig.xml index c3b4efd8..c158c7bc 100644 --- a/sim/contrib/examples/Configurations/PCM/slaveConfig.xml +++ b/sim/contrib/examples/Configurations/PCM/slaveConfig.xml @@ -25,6 +25,7 @@ + Germany -- GitLab