Skip to content

Commit

Permalink
Merge pull request #1121 from tier4/fix/sign-of-relative-distance
Browse files Browse the repository at this point in the history
Fix/sign of relative distance
  • Loading branch information
HansRobo authored Nov 2, 2023
2 parents c4b7daa + 6801847 commit d2a5a33
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
7 changes: 4 additions & 3 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Major Changes :race_car: :red_car: :blue_car:

Bug Fixes:bug:

| Feature | Brief summary | Category | Pull request | Contributor |
|---------------------------|---------------------------------------------------------------------------------|---------------------|-------------------------------------------------------------------|---------------------------------------------|
| Deleted entity management | Fix crash caused by `DeleteEntityAction` by handling deleted entity explicitly. | `traffic_simulator` | [#1096](https://github.com/tier4/scenario_simulator_v2/pull/1096) | [f0reachARR](https://github.com/f0reachARR) |
| Feature | Brief summary | Category | Pull request | Contributor |
|------------------------------------------|------------------------------------------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------|-----------------------------------------------|
| Deleted entity management | Fix crash caused by `DeleteEntityAction` by handling deleted entity explicitly. | `traffic_simulator` | [#1096](https://github.com/tier4/scenario_simulator_v2/pull/1096) | [f0reachARR](https://github.com/f0reachARR) |
| 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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().is_added) {
return makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.x;
return std::abs(makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.x);
} else {
return Double::nan();
}
Expand All @@ -76,7 +76,8 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().is_added) {
return makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.x;
return std::abs(
makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.x);
} else {
return Double::nan();
}
Expand All @@ -90,7 +91,7 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().is_added) {
return makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.y;
return std::abs(makeNativeRelativeWorldPosition(triggering_entity, entity_ref).position.y);
} else {
return Double::nan();
}
Expand All @@ -104,7 +105,8 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().is_added) {
return makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.y;
return std::abs(
makeNativeBoundingBoxRelativeWorldPosition(triggering_entity, entity_ref).position.y);
} else {
return Double::nan();
}
Expand Down Expand Up @@ -150,6 +152,18 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(entity_ref).as<ScenarioObject>().is_added and
global().entities->at(triggering_entity).as<ScenarioObject>().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<traffic_simulator::LaneletPose>(
makeNativeRelativeLanePosition(triggering_entity, entity_ref))
.offset;
Expand All @@ -166,6 +180,18 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(entity_ref).as<ScenarioObject>().is_added and
global().entities->at(triggering_entity).as<ScenarioObject>().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<traffic_simulator::LaneletPose>(
makeNativeBoundingBoxRelativeLanePosition(triggering_entity, entity_ref))
.offset;
Expand All @@ -182,6 +208,18 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().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<traffic_simulator::LaneletPose>(
makeNativeRelativeLanePosition(triggering_entity, entity_ref))
.s;
Expand All @@ -198,6 +236,18 @@ auto RelativeDistanceCondition::distance<
if (
global().entities->at(triggering_entity).as<ScenarioObject>().is_added and
global().entities->at(entity_ref).as<ScenarioObject>().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<traffic_simulator::LaneletPose>(
makeNativeBoundingBoxRelativeLanePosition(triggering_entity, entity_ref))
.s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2a5a33

Please sign in to comment.