Skip to content

Commit 7f368a2

Browse files
authored
fix(avoidance): fix bug in the logic to check object moving distance (#6766)
fix(avoidance): check object moving distance Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 44c6169 commit 7f368a2

File tree

4 files changed

+13
-33
lines changed

4 files changed

+13
-33
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/scene.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,6 @@ class AvoidanceModule : public SceneModuleInterface
424424
// TODO(Satoshi OTA) create detected object manager.
425425
ObjectDataArray registered_objects_;
426426

427-
// TODO(Satoshi OTA) remove mutable.
428-
mutable ObjectDataArray detected_objects_;
429-
430427
// TODO(Satoshi OTA) remove this variable.
431428
mutable ObjectDataArray ego_stopped_objects_;
432429

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/utils.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ void fillObjectStoppableJudge(
115115
ObjectData & object_data, const ObjectDataArray & registered_objects,
116116
const double feasible_stop_distance, const std::shared_ptr<AvoidanceParameters> & parameters);
117117

118-
void fillInitialPose(ObjectData & object_data, ObjectDataArray & detected_objects);
119-
120118
void updateRegisteredObject(
121119
ObjectDataArray & registered_objects, const ObjectDataArray & now_objects,
122120
const std::shared_ptr<AvoidanceParameters> & parameters);

planning/behavior_path_avoidance_module/src/scene.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ ObjectData AvoidanceModule::createObjectData(
410410
// Calc moving time.
411411
utils::avoidance::fillObjectMovingTime(object_data, stopped_objects_, parameters_);
412412

413-
// Fill init pose.
414-
utils::avoidance::fillInitialPose(object_data, detected_objects_);
415-
416413
// Calc lateral deviation from path to target object.
417414
object_data.direction = calcLateralDeviation(object_closest_pose, object_pose.position) > 0.0
418415
? Direction::LEFT

planning/behavior_path_avoidance_module/src/utils.cpp

+13-25
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,6 @@ bool isNeverAvoidanceTarget(
551551
const std::shared_ptr<const PlannerData> & planner_data,
552552
const std::shared_ptr<AvoidanceParameters> & parameters)
553553
{
554-
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
555-
const auto is_moving_distance_longer_than_threshold =
556-
tier4_autoware_utils::calcDistance2d(object.init_pose, object_pose) >
557-
parameters->distance_threshold_for_ambiguous_vehicle;
558-
if (is_moving_distance_longer_than_threshold) {
559-
object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
560-
return true;
561-
}
562-
563554
if (object.is_within_intersection) {
564555
if (object.behavior == ObjectData::Behavior::NONE) {
565556
object.reason = "ParallelToEgoLane";
@@ -752,6 +743,15 @@ bool isSatisfiedWithVehicleCondition(
752743
return false;
753744
}
754745

746+
const auto & current_pose = object.object.kinematics.initial_pose_with_covariance.pose;
747+
const auto is_moving_distance_longer_than_threshold =
748+
calcDistance2d(object.init_pose, current_pose) >
749+
parameters->distance_threshold_for_ambiguous_vehicle;
750+
if (is_moving_distance_longer_than_threshold) {
751+
object.reason = "AmbiguousStoppedVehicle";
752+
return false;
753+
}
754+
755755
if (object.is_within_intersection) {
756756
if (object.behavior == ObjectData::Behavior::DEVIATING) {
757757
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
@@ -1384,6 +1384,7 @@ void fillObjectMovingTime(
13841384
object_data.last_stop = now;
13851385
object_data.move_time = 0.0;
13861386
if (is_new_object) {
1387+
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
13871388
object_data.stop_time = 0.0;
13881389
object_data.last_move = now;
13891390
stopped_objects.push_back(object_data);
@@ -1392,11 +1393,13 @@ void fillObjectMovingTime(
13921393
same_id_obj->last_stop = now;
13931394
same_id_obj->move_time = 0.0;
13941395
object_data.stop_time = same_id_obj->stop_time;
1396+
object_data.init_pose = same_id_obj->init_pose;
13951397
}
13961398
return;
13971399
}
13981400

13991401
if (is_new_object) {
1402+
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
14001403
object_data.move_time = std::numeric_limits<double>::infinity();
14011404
object_data.stop_time = 0.0;
14021405
object_data.last_move = now;
@@ -1406,6 +1409,7 @@ void fillObjectMovingTime(
14061409
object_data.last_stop = same_id_obj->last_stop;
14071410
object_data.move_time = (now - same_id_obj->last_stop).seconds();
14081411
object_data.stop_time = 0.0;
1412+
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
14091413

14101414
if (object_data.move_time > object_parameter.moving_time_threshold) {
14111415
stopped_objects.erase(same_id_obj);
@@ -1452,22 +1456,6 @@ void fillAvoidanceNecessity(
14521456
object_data.avoid_required = check_necessity(parameters->hysteresis_factor_expand_rate);
14531457
}
14541458

1455-
void fillInitialPose(ObjectData & object_data, ObjectDataArray & detected_objects)
1456-
{
1457-
const auto id = object_data.object.object_id;
1458-
const auto same_id_obj = std::find_if(
1459-
detected_objects.begin(), detected_objects.end(),
1460-
[&id](const auto & o) { return o.object.object_id == id; });
1461-
1462-
if (same_id_obj != detected_objects.end()) {
1463-
object_data.init_pose = same_id_obj->init_pose;
1464-
return;
1465-
}
1466-
1467-
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
1468-
detected_objects.push_back(object_data);
1469-
}
1470-
14711459
void fillObjectStoppableJudge(
14721460
ObjectData & object_data, const ObjectDataArray & registered_objects,
14731461
const double feasible_stop_distance, const std::shared_ptr<AvoidanceParameters> & parameters)

0 commit comments

Comments
 (0)