Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(static_obstacle_avoidance): stop position is unstable #7880

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

satoshi-ota
Copy link
Contributor

@satoshi-ota satoshi-ota commented Jul 7, 2024

Description

This module compensates object even after the system lost them until the time has passed more than threshold.

However, since the longitudinal distance of compensated object was not updated, the avoidance stop point was not calculated expectedly. 0:30~ in following movie, the stop point moved forward even though the target object kept stopping.

simplescreenrecorder-2024-07-05_10.14.07.mp4

In this PR, I fixed to update longitudinal for compensated objects in following function.

void compensateLostTargetObjects(
  ObjectDataArray & stored_objects, AvoidancePlanningData & data, const rclcpp::Time & now,
  const std::shared_ptr<const PlannerData> & planner_data,
  const std::shared_ptr<AvoidanceParameters> & parameters)
{
  const auto include = [](const auto & objects, const auto & search_id) {
    return std::all_of(objects.begin(), objects.end(), [&search_id](const auto & o) {
      return o.object.object_id != search_id;
    });
  };

  // STEP.1 UPDATE STORED OBJECTS.
  const auto match = [&data](auto & object) {
    const auto & search_id = object.object.object_id;
    const auto same_id_object = std::find_if(
      data.target_objects.begin(), data.target_objects.end(),
      [&search_id](const auto & o) { return o.object.object_id == search_id; });

    // same id object is detected. update registered.
    if (same_id_object != data.target_objects.end()) {
      object = *same_id_object;
      return true;
    }

    const auto similar_pos_obj = std::find_if(
      data.target_objects.begin(), data.target_objects.end(), [&object](const auto & o) {
        constexpr auto POS_THR = 1.5;
        return calcDistance2d(object.getPose(), o.getPose()) < POS_THR;
      });

    // same id object is not detected, but object is found around registered. update registered.
    if (similar_pos_obj != data.target_objects.end()) {
      object = *similar_pos_obj;
      return true;
    }

    // Same ID nor similar position object does not found.
    return false;
  };

  // STEP1-1: REMOVE EXPIRED OBJECTS.
  const auto itr = std::remove_if(
    stored_objects.begin(), stored_objects.end(), [&now, &match, &parameters](auto & o) {
      if (!match(o)) {
        o.lost_time = (now - o.last_seen).seconds();
      } else {
        o.last_seen = now;
        o.lost_time = 0.0;
      }

      return o.lost_time > parameters->object_last_seen_threshold;
    });

  stored_objects.erase(itr, stored_objects.end());

  // STEP1-2: UPDATE STORED OBJECTS IF THERE ARE NEW OBJECTS.
  for (const auto & current_object : data.target_objects) {
    if (!include(stored_objects, current_object.object.object_id)) {
      stored_objects.push_back(current_object);
    }
  }

  // STEP2: COMPENSATE CURRENT TARGET OBJECTS
  const auto is_detected = [&](const auto & object_id) {
    return std::any_of(
      data.target_objects.begin(), data.target_objects.end(),
      [&object_id](const auto & o) { return o.object.object_id == object_id; });
  };

  const auto is_ignored = [&](const auto & object_id) {
    return std::any_of(
      data.other_objects.begin(), data.other_objects.end(),
      [&object_id](const auto & o) { return o.object.object_id == object_id; });
  };

  for (auto & stored_object : stored_objects) {
    if (is_detected(stored_object.object.object_id)) {
      continue;
    }
    if (is_ignored(stored_object.object.object_id)) {
      continue;
    }

    const auto & ego_pos = planner_data->self_odometry->pose.pose.position;
    fillLongitudinalAndLengthByClosestEnvelopeFootprint(
      data.reference_path_rough, ego_pos, stored_object);

    data.target_objects.push_back(stored_object);
  }
}

Related links

Parent Issue:

How was this PR tested?

  • Psim + reproducer
simplescreenrecorder-2024-07-08_08.23.27.mp4

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label Jul 7, 2024
Copy link

github-actions bot commented Jul 7, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@satoshi-ota satoshi-ota force-pushed the fix/stop-position-bug branch from 2290c05 to ca065a0 Compare July 8, 2024 00:15
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
@satoshi-ota satoshi-ota force-pushed the fix/stop-position-bug branch from ca065a0 to c57baf1 Compare July 8, 2024 00:19
@satoshi-ota satoshi-ota marked this pull request as ready for review July 8, 2024 02:40
@go-sakayori go-sakayori self-assigned this Jul 8, 2024
Copy link
Contributor

@rej55 rej55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@satoshi-ota satoshi-ota added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Jul 9, 2024
@satoshi-ota satoshi-ota enabled auto-merge (squash) July 9, 2024 22:53
@satoshi-ota satoshi-ota merged commit 050fa29 into autowarefoundation:main Jul 9, 2024
41 of 42 checks passed
@satoshi-ota satoshi-ota deleted the fix/stop-position-bug branch July 9, 2024 23:13
Ariiees pushed a commit to Ariiees/autoware.universe that referenced this pull request Jul 22, 2024
…undation#7880)

fix(static_obstacle_avoidance): fix stop position

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
satoshi-ota added a commit to tier4/autoware.universe that referenced this pull request Jul 29, 2024
…undation#7880)

fix(static_obstacle_avoidance): fix stop position

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
satoshi-ota added a commit to tier4/autoware.universe that referenced this pull request Jul 31, 2024
…undation#7880)

fix(static_obstacle_avoidance): fix stop position

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants