PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
10k stars 4.62k forks source link

[Eigen Memory.h] PCL 1.11.1 -> PCL 1.14.1, the same code went wrong #6167

Open Neo-YH opened 2 days ago

Neo-YH commented 2 days ago

Describe the bug

PCL 1.11.1 -> PCL 1.14.1, the same code went wrong It might be my fault, but I couldn't find the reason. Sorry for put the question here.

Context

void pcltools::filter_passthrough(pcl::PointCloud<pcl::PointXYZ>::Ptr Inputcloud, pcl::PointCloud<pcl::PointXYZ>::Ptr filteredcloud, double min_bound, double max_bound, string axis)
{
    pcl::PassThrough<pcl::PointXYZ> pass;
    pass.setInputCloud(Inputcloud);           
    pass.setFilterFieldName(axis);         
    pass.setFilterLimits(min_bound, max_bound);        
    pass.filter(*filteredcloud);            
}

I want to define this function, it can be successfully invoked in PCL 1.11.1, but went wrong in PCL 1.14.1. Does PCL 1.14.1 have stricter memory management?

Expected behavior

filter_passthrough(cloud_input, cloud_in_parkinglot, PARKINGLOT_X_MIN, PARKINGLOT_X_MAX, "x"); I hope that similar types of syntax can be executed correctly.

Current Behavior

/** \internal Frees memory allocated with aligned_malloc. */
EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)
{
  #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED

    EIGEN_USING_STD(free)
    free(ptr);

  #else
    handmade_aligned_free(ptr);
  #endif
}

In PCL 1.14.1, calling free(ptr) sometimes triggers an error, whereas PCL 1.11.1 does not trigger this error.

Your Environment (please complete the following information):

Possible Solution

Has PCL 1.14.1 introduced stricter restrictions, such as ensuring that the input or output point clouds for filters cannot be null? The issue I'm encountering doesn't seem to be caused by an empty point cloud, but I suspect there may be such limitations.

mvieth commented 2 days ago

@Neo-YH Hi, do you use CMake to build your code? If not, I would recommend you to use it. There are some compiler options that need to be set the same when compiling PCL and when compiling your own code (e.g. AVX/AVX2 enabled). CMake automatically takes care of this. It is possible to set these manually in Visual Studio, but using CMake is easier. See also https://pcl.readthedocs.io/projects/tutorials/en/master/using_pcl_pcl_config.html

Neo-YH commented 2 days ago

@mvieth Thank you so much for your reply. I'm using released all-in-one package.

[PCL-1.14.1-AllInOne-msvc2022-win64.exe](https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.14.1/PCL-1.14.1-AllInOne-msvc2022-win64.exe

Is it ok to use this, or should I build PCL from source using CMake? Could using PCL-1.14.1-AllInOne-msvc2022-win64.exe cause any issues?

mvieth commented 2 days ago

@Neo-YH Using the AllInOne installer is fine, but like I said, I would recommend you to use CMake when compiling your own code/your own project. Then you should be able to use the AllInOne installer without problems.

Neo-YH commented 2 days ago

I will have a try. I'll reach out to you again if I run into any problems. Thank you for your help