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

feat(behavior_path_planner): update filter objects by velocity #4742

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ PredictedObjects filterObjects(
* @param lim_v Velocity limit for filtering.
* @return PredictedObjects The filtered objects.
*/
PredictedObjects filterObjectsByVelocity(const PredictedObjects & objects, double lim_v);
PredictedObjects filterObjectsByVelocity(
const PredictedObjects & objects, const double lim_v, const bool filter_dynamic_objects = true);
Copy link
Contributor

Choose a reason for hiding this comment

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

dynamic_objects means objects whose velocity is larger than lim_v

Copy link
Contributor

Choose a reason for hiding this comment

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

a little unclear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kosuke55
I agree.

a little unclear

How about this?

/**
 * @brief Filters objects based on their velocity.
 *
 * Depending on the remove_above_threshold parameter, this function either removes objects with
 * velocities above the given threshold or only keeps those objects. It uses the helper function
 * filterObjectsByVelocity() to do the actual filtering.
 *
 * @param objects The objects to be filtered.
 * @param velocity_threshold The velocity threshold for the filtering.
 * @param remove_above_threshold If true, objects with velocities above the threshold are removed.
 *                               If false, only objects with velocities above the threshold are kept.
 * @return A new collection of objects that have been filtered according to the rules.
 */
PredictedObjects filterObjectsByVelocity(
  const PredictedObjects & objects, const double velocity_threshold,
  const bool remove_above_threshold)

Copy link
Contributor

Choose a reason for hiding this comment

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

nice! thanks!!


/**
* @brief Filter objects based on a velocity range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PredictedObjects filterObjects(

PredictedObjects filtered_objects;

filtered_objects = filterObjectsByVelocity(*objects, ignore_object_velocity_threshold);
filtered_objects = filterObjectsByVelocity(*objects, ignore_object_velocity_threshold, false);

filterObjectsByClass(filtered_objects, target_object_types);

Expand All @@ -51,9 +51,14 @@ PredictedObjects filterObjects(
return filtered_objects;
}

PredictedObjects filterObjectsByVelocity(const PredictedObjects & objects, double lim_v)
PredictedObjects filterObjectsByVelocity(
const PredictedObjects & objects, double lim_v, const bool filter_dynamic_objects)
{
return filterObjectsByVelocity(objects, -lim_v, lim_v);
if (filter_dynamic_objects) {
return filterObjectsByVelocity(objects, -lim_v, lim_v);
} else {
return filterObjectsByVelocity(objects, lim_v, std::numeric_limits<double>::max());
}
}

PredictedObjects filterObjectsByVelocity(
Expand Down