Skip to content

Commit 161e23d

Browse files
authored
fix(avoidance): fix visualization bug (autowarefoundation#3586)
fix(avoidance): ignore objects whose shift line length is less than threshold Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent ca9e277 commit 161e23d

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

planning/behavior_path_planner/include/behavior_path_planner/utils/avoidance/utils.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ bool isTargetObjectType(
3434
double calcShiftLength(
3535
const bool & is_object_on_right, const double & overhang_dist, const double & avoid_margin);
3636

37+
bool isShiftNecessary(const bool & is_object_on_right, const double & shift_length);
38+
3739
bool isSameDirectionShift(const bool & is_object_on_right, const double & shift_length);
3840

3941
size_t findPathIndexFromArclength(

planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,7 @@ void AvoidanceModule::updateDebugMarker(
33133313
add(createOtherObjectsMarkerArray(data.other_objects, AvoidanceDebugFactor::NOT_PARKING_OBJECT));
33143314
add(createOtherObjectsMarkerArray(data.other_objects, std::string("MovingObject")));
33153315
add(createOtherObjectsMarkerArray(data.other_objects, std::string("OutOfTargetArea")));
3316+
add(createOtherObjectsMarkerArray(data.other_objects, std::string("NotNeedAvoidance")));
33163317

33173318
add(makeOverhangToRoadShoulderMarkerArray(data.target_objects, "overhang"));
33183319
add(createOverhangFurthestLineStringMarkerArray(

planning/behavior_path_planner/src/utils/avoidance/utils.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,32 @@ double calcShiftLength(
9696
return std::fabs(shift_length) > 1e-3 ? shift_length : 0.0;
9797
}
9898

99+
bool isShiftNecessary(const bool & is_object_on_right, const double & shift_length)
100+
{
101+
/**
102+
* ^
103+
* |
104+
* --+----x-------------------------------x--->
105+
* | x x
106+
* | ==obj==
107+
*/
108+
if (is_object_on_right && shift_length < 0.0) {
109+
return false;
110+
}
111+
112+
/**
113+
* ^ ==obj==
114+
* | x x
115+
* --+----x-------------------------------x--->
116+
* |
117+
*/
118+
if (!is_object_on_right && shift_length > 0.0) {
119+
return false;
120+
}
121+
122+
return true;
123+
}
124+
99125
bool isSameDirectionShift(const bool & is_object_on_right, const double & shift_length)
100126
{
101127
return (is_object_on_right == std::signbit(shift_length));
@@ -683,6 +709,15 @@ void filterTargetObjects(
683709
return std::min(max_allowable_lateral_distance, max_avoid_margin);
684710
}();
685711

712+
if (!!avoid_margin) {
713+
const auto shift_length = calcShiftLength(isOnRight(o), o.overhang_dist, avoid_margin.get());
714+
if (!isShiftNecessary(isOnRight(o), shift_length)) {
715+
o.reason = "NotNeedAvoidance";
716+
data.other_objects.push_back(o);
717+
continue;
718+
}
719+
}
720+
686721
// force avoidance for stopped vehicle
687722
{
688723
const auto to_traffic_light =

0 commit comments

Comments
 (0)