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

Function 'filterPointCloudByTrajectory' does not work as intended #584

Closed
3 tasks done
maxime-clem opened this issue Mar 25, 2022 · 0 comments
Closed
3 tasks done
Assignees
Labels
priority:high High urgency and importance. priority:low Lower urgency, can be addressed later. type:bug Software flaws or errors.

Comments

@maxime-clem
Copy link
Contributor

maxime-clem commented Mar 25, 2022

Checklist

  • I've read the contribution guidelines.
  • I've searched other issues and no duplicate issues were found.
  • I'm convinced that this is not my fault but a bug.

Description

Function filterPointCloudByTrajectory is used to filter a point cloud and only keep the points that are within a given distance from a trajectory. The current implementation is wrong and can return a point cloud with duplicate points and can be larger than the original point cloud.

pcl::PointCloud<pcl::PointXYZ> filterPointCloudByTrajectory(
const pcl::PointCloud<pcl::PointXYZ> & pointcloud,
const autoware_auto_planning_msgs::msg::Trajectory & trajectory, const double radius)
{
pcl::PointCloud<pcl::PointXYZ> filtered_pointcloud;
for (const auto & trajectory_point : trajectory.points) {
for (const auto & point : pointcloud.points) {
const double dx = trajectory_point.pose.position.x - point.x;
const double dy = trajectory_point.pose.position.y - point.y;
if (std::hypot(dx, dy) < radius) {
filtered_pointcloud.points.push_back(point);
}
}
}
return filtered_pointcloud;
}

Expected behavior

Function filterPointCloudByTrajectory returns a point cloud of size at most equal to the size of the input.

Actual behavior

Function filterPointCloudByTrajectory can return a point cloud larger than the input.

Steps to reproduce

Passing a very large radius will cause the bug.

Versions

No response

Possible causes

The same point from the point cloud can be added multiple time if close enough to multiple trajectory_point.

Additional context

Possible fix:

for (const auto & point : pointcloud.points) {
    for (const auto & trajectory_point : trajectory.points) {
      const double dx = trajectory_point.pose.position.x - point.x;
      const double dy = trajectory_point.pose.position.y - point.y;
      if (std::hypot(dx, dy) < radius) {
        filtered_pointcloud.points.push_back(point);
        break;
      }
    }
  }
@maxime-clem maxime-clem added type:bug Software flaws or errors. priority:low Lower urgency, can be addressed later. labels Mar 25, 2022
@maxime-clem maxime-clem self-assigned this Mar 25, 2022
@xmfcx xmfcx added the priority:high High urgency and importance. label Mar 29, 2022
@maxime-clem maxime-clem changed the title Function 'filterPointCloudByTrajectory' Function 'filterPointCloudByTrajectory' does not work as intended Mar 29, 2022
@BonoloAWF BonoloAWF moved this to Done in Bus ODD Project Jul 12, 2022
dmoszynski pushed a commit to RobotecAI/autoware.universe that referenced this issue Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high High urgency and importance. priority:low Lower urgency, can be addressed later. type:bug Software flaws or errors.
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants