From 124792413e03793dc88e36e2f4e09bbc21e88476 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Fri, 27 Oct 2023 17:14:52 +0900 Subject: [PATCH 1/4] Fix some `RelativeDistanceCondition` mode to return non-negative value Signed-off-by: yamacir-kit --- .../src/syntax/relative_distance_condition.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp b/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp index fff1885f274..5dfa9df89b5 100644 --- a/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp @@ -62,7 +62,7 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { - return makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.x; + return std::abs(makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.x); } else { return Double::nan(); } @@ -76,7 +76,8 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { - return makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.x; + return std::abs( + makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.x); } else { return Double::nan(); } @@ -90,7 +91,7 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { - return makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.y; + return std::abs(makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.y); } else { return Double::nan(); } @@ -104,7 +105,8 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { - return makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.y; + return std::abs( + makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.y); } else { return Double::nan(); } From 9b7851f9a621f6ee498d406bffb5bcff59f31a6a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Fri, 27 Oct 2023 17:27:13 +0900 Subject: [PATCH 2/4] Add comments about the historical background of `RelativeDistanceCondition`'s behavior Signed-off-by: yamacir-kit --- .../syntax/relative_distance_condition.cpp | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp b/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp index 5dfa9df89b5..e2669fd8dfe 100644 --- a/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/relative_distance_condition.cpp @@ -152,6 +152,18 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(entity_ref).as().is_added and global().entities->at(triggering_entity).as().is_added) { + /* + For historical reasons, signed distances are returned when + coordinateSystem == lane and relativeDistanceType == + longitudinal/lateral. The sign has been mainly used to determine the + front/back and left/right positional relationship (a negative value is + returned if the target entity is behind or to the right). + + This behavior violates the OpenSCENARIO standard. In the future, after + DistanceCondition and RelativeDistanceCondition of TIER IV's + OpenSCENARIO Interpreter support OpenSCENARIO 1.2 RoutingAlgorithm, this + behavior will be enabled only when routingAlgorithm == undefined. + */ return static_cast( makeNativeRelativeLanePosition(triggering_entity, entity_ref)) .offset; @@ -168,6 +180,18 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(entity_ref).as().is_added and global().entities->at(triggering_entity).as().is_added) { + /* + For historical reasons, signed distances are returned when + coordinateSystem == lane and relativeDistanceType == + longitudinal/lateral. The sign has been mainly used to determine the + front/back and left/right positional relationship (a negative value is + returned if the target entity is behind or to the right). + + This behavior violates the OpenSCENARIO standard. In the future, after + DistanceCondition and RelativeDistanceCondition of TIER IV's + OpenSCENARIO Interpreter support OpenSCENARIO 1.2 RoutingAlgorithm, this + behavior will be enabled only when routingAlgorithm == undefined. + */ return static_cast( makeNativeBoundingBoxRelativeLanePosition(triggering_entity, entity_ref)) .offset; @@ -184,6 +208,18 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { + /* + For historical reasons, signed distances are returned when + coordinateSystem == lane and relativeDistanceType == + longitudinal/lateral. The sign has been mainly used to determine the + front/back and left/right positional relationship (a negative value is + returned if the target entity is behind or to the right). + + This behavior violates the OpenSCENARIO standard. In the future, after + DistanceCondition and RelativeDistanceCondition of TIER IV's + OpenSCENARIO Interpreter support OpenSCENARIO 1.2 RoutingAlgorithm, this + behavior will be enabled only when routingAlgorithm == undefined. + */ return static_cast( makeNativeRelativeLanePosition(triggering_entity, entity_ref)) .s; @@ -200,6 +236,18 @@ auto RelativeDistanceCondition::distance< if ( global().entities->at(triggering_entity).as().is_added and global().entities->at(entity_ref).as().is_added) { + /* + For historical reasons, signed distances are returned when + coordinateSystem == lane and relativeDistanceType == + longitudinal/lateral. The sign has been mainly used to determine the + front/back and left/right positional relationship (a negative value is + returned if the target entity is behind or to the right). + + This behavior violates the OpenSCENARIO standard. In the future, after + DistanceCondition and RelativeDistanceCondition of TIER IV's + OpenSCENARIO Interpreter support OpenSCENARIO 1.2 RoutingAlgorithm, this + behavior will be enabled only when routingAlgorithm == undefined. + */ return static_cast( makeNativeBoundingBoxRelativeLanePosition(triggering_entity, entity_ref)) .s; From 3c49d310bcaf158696bd74b576eeb14716c5f457 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Fri, 27 Oct 2023 18:29:14 +0900 Subject: [PATCH 3/4] Update ReleaseNotes Signed-off-by: yamacir-kit --- docs/ReleaseNotes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 58362e164fa..56fae2e615e 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -12,9 +12,9 @@ Major Changes :race_car: :red_car: :blue_car: Bug Fixes:bug: -| Feature | Brief summary | Category | Pull request | Contributor | -|---------|---------------|----------|--------------|-------------| -| | | | | | +| Feature | Brief summary | Category | Pull request | Contributor | +|------------------------------------------|------------------------------------------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------|-----------------------------------------------| +| OpenSCENARIO `RelativeDistanceCondition` | Restore the behavior of the existing distance measurement mode of RelativeDistanceCondition that was changed in #1095. | `openscenario_interpreter` | [#1121](https://github.com/tier4/scenario_simulator_v2/pull/1121) | [yamacir-kit](https://github.com/yamacir-kit) | Minor Tweaks :oncoming_police_car: From bb3f258706b7e58e70381a4de93b65527f803006 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 30 Oct 2023 13:38:45 +0900 Subject: [PATCH 4/4] Update test scenario to not expect negative distance for `RelativeDistanceCondition` in non-lane coordinate systems Signed-off-by: yamacir-kit --- ...tion.EntityCondition.RelativeDistanceConditionFreespace.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_runner/scenario_test_runner/scenario/ByEntityCondition.EntityCondition.RelativeDistanceConditionFreespace.yaml b/test_runner/scenario_test_runner/scenario/ByEntityCondition.EntityCondition.RelativeDistanceConditionFreespace.yaml index de7f4f08282..13bce0cd036 100644 --- a/test_runner/scenario_test_runner/scenario/ByEntityCondition.EntityCondition.RelativeDistanceConditionFreespace.yaml +++ b/test_runner/scenario_test_runner/scenario/ByEntityCondition.EntityCondition.RelativeDistanceConditionFreespace.yaml @@ -129,7 +129,7 @@ OpenSCENARIO: freespace: true # True: distance is measured between closest bounding box points. False: reference point distance is used. relativeDistanceType: lateral rule: equalTo - value: -0.1700000000055297 + value: 0.1700000000055297 - name: "" delay: 0 conditionEdge: none