Skip to content

Commit

Permalink
fix(avoidance): fix bug in the logic to check object moving distance (a…
Browse files Browse the repository at this point in the history
…utowarefoundation#6766)

fix(avoidance): check object moving distance

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed May 10, 2024
1 parent bff6714 commit 0dc9544
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ class AvoidanceModule : public SceneModuleInterface
// TODO(Satoshi OTA) create detected object manager.
ObjectDataArray registered_objects_;

// TODO(Satoshi OTA) remove mutable.
mutable ObjectDataArray detected_objects_;

// TODO(Satoshi OTA) remove this variable.
mutable ObjectDataArray ego_stopped_objects_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ void fillObjectStoppableJudge(
ObjectData & object_data, const ObjectDataArray & registered_objects,
const double feasible_stop_distance, const std::shared_ptr<AvoidanceParameters> & parameters);

void fillInitialPose(ObjectData & object_data, ObjectDataArray & detected_objects);

void updateRegisteredObject(
ObjectDataArray & registered_objects, const ObjectDataArray & now_objects,
const std::shared_ptr<AvoidanceParameters> & parameters);
Expand Down
3 changes: 0 additions & 3 deletions planning/behavior_path_avoidance_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,6 @@ ObjectData AvoidanceModule::createObjectData(
// Calc moving time.
utils::avoidance::fillObjectMovingTime(object_data, stopped_objects_, parameters_);

// Fill init pose.
utils::avoidance::fillInitialPose(object_data, detected_objects_);

// Calc lateral deviation from path to target object.
object_data.direction = calcLateralDeviation(object_closest_pose, object_pose.position) > 0.0
? Direction::LEFT
Expand Down
38 changes: 13 additions & 25 deletions planning/behavior_path_avoidance_module/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,6 @@ bool isNeverAvoidanceTarget(
const std::shared_ptr<const PlannerData> & planner_data,
const std::shared_ptr<AvoidanceParameters> & parameters)
{
const auto & object_pose = object.object.kinematics.initial_pose_with_covariance.pose;
const auto is_moving_distance_longer_than_threshold =
tier4_autoware_utils::calcDistance2d(object.init_pose, object_pose) >
parameters->distance_threshold_for_ambiguous_vehicle;
if (is_moving_distance_longer_than_threshold) {
object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
return true;
}

if (object.is_within_intersection) {
if (object.behavior == ObjectData::Behavior::NONE) {
object.reason = "ParallelToEgoLane";
Expand Down Expand Up @@ -856,6 +847,15 @@ bool isSatisfiedWithVehicleCondition(
return false;
}

const auto & current_pose = object.object.kinematics.initial_pose_with_covariance.pose;
const auto is_moving_distance_longer_than_threshold =
calcDistance2d(object.init_pose, current_pose) >
parameters->distance_threshold_for_ambiguous_vehicle;
if (is_moving_distance_longer_than_threshold) {
object.reason = "AmbiguousStoppedVehicle";
return false;
}

if (object.is_within_intersection) {
if (object.behavior == ObjectData::Behavior::DEVIATING) {
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
Expand Down Expand Up @@ -1488,6 +1488,7 @@ void fillObjectMovingTime(
object_data.last_stop = now;
object_data.move_time = 0.0;
if (is_new_object) {
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
object_data.stop_time = 0.0;
object_data.last_move = now;
stopped_objects.push_back(object_data);
Expand All @@ -1496,11 +1497,13 @@ void fillObjectMovingTime(
same_id_obj->last_stop = now;
same_id_obj->move_time = 0.0;
object_data.stop_time = same_id_obj->stop_time;
object_data.init_pose = same_id_obj->init_pose;
}
return;
}

if (is_new_object) {
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
object_data.move_time = std::numeric_limits<double>::infinity();
object_data.stop_time = 0.0;
object_data.last_move = now;
Expand All @@ -1510,6 +1513,7 @@ void fillObjectMovingTime(
object_data.last_stop = same_id_obj->last_stop;
object_data.move_time = (now - same_id_obj->last_stop).seconds();
object_data.stop_time = 0.0;
object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;

if (object_data.move_time > object_parameter.moving_time_threshold) {
stopped_objects.erase(same_id_obj);
Expand Down Expand Up @@ -1556,22 +1560,6 @@ void fillAvoidanceNecessity(
object_data.avoid_required = check_necessity(parameters->hysteresis_factor_expand_rate);
}

void fillInitialPose(ObjectData & object_data, ObjectDataArray & detected_objects)
{
const auto id = object_data.object.object_id;
const auto same_id_obj = std::find_if(
detected_objects.begin(), detected_objects.end(),
[&id](const auto & o) { return o.object.object_id == id; });

if (same_id_obj != detected_objects.end()) {
object_data.init_pose = same_id_obj->init_pose;
return;
}

object_data.init_pose = object_data.object.kinematics.initial_pose_with_covariance.pose;
detected_objects.push_back(object_data);
}

void fillObjectStoppableJudge(
ObjectData & object_data, const ObjectDataArray & registered_objects,
const double feasible_stop_distance, const std::shared_ptr<AvoidanceParameters> & parameters)
Expand Down

0 comments on commit 0dc9544

Please sign in to comment.