0
$\begingroup$

I am getting a segmentation fault with pcl::transformPointCloud.

This is all I am getting on the terminal:

ros2 run cpp_tests icp_test
initialized
101201
Transforming
[ros2run]: Segmentation fault

My PCL version is 1.12.1.

The line that is causing the error is:

pcl::transformPointCloud(*cloud_in, *cloud_icp, icp_transform);

cloud_in and cloud_icp are both pcl::PointCloud<pcl::PointXYZ>::Ptr, and icp_transform is obtained from PCL and is Eigen::Matrix4f. cloud_in had the input cloud in it, cloud_icp would be empty (it was defined as pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_icp; but not used before this point).

I would like to solve this issue or find a workaround. As far as I can tell, I have only PCL 1.12.1 on my system. I am using ROS2 humble on Ubuntu 22.04. This was compiled using colcon build --symlink-install and compiled without any errors.

Thanks.

$\endgroup$

2 Answers 2

1
$\begingroup$

With the definition of cloud_icp from your first post, you just declare a pointer of type¹

pcl::PointCloud<pcl::PointXYZ>

However, its not pointing to an existing pcl::PointCloud<pcl::PointXYZ> Pointcloud and thus your program crashes when entering the function.
The approach from your own answer

cloud_icp = pcl::PointCloud<pcl::PointXYZ>::Ptr (new pcl::PointCloud<pcl::PointXYZ>(360,1));

creates an underlying Pointcloud.

¹: More precisely, it is a smart pointer of type std::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>.

$\endgroup$
0
$\begingroup$

I found a workaround. Adding

cloud_icp = pcl::PointCloud<pcl::PointXYZ>::Ptr (new pcl::PointCloud<pcl::PointXYZ>(360,1));

to the constructor solved the problem. I don't know why that helped.

$\endgroup$
3
  • $\begingroup$ With the definition of cloud_icp from your first post, you just declare a pointer of type pcl::PointCloud<pcl::PointXYZ> (but its not pointing to an existing pcl::PointCloud<pcl::PointXYZ> Pointcloud and thus your program crashes when entering the function). The approach in your own answer creates an underlying Pointcloud. $\endgroup$
    – Bi0T1N
    Sep 16, 2023 at 14:39
  • $\begingroup$ Thank you! Would you be able to add that as an answer? $\endgroup$ Sep 18, 2023 at 7:18
  • $\begingroup$ I advise you to read up on c++ a bit; I found Learn C++ a very good resource. $\endgroup$
    – JRTG
    Sep 19, 2023 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.