norlab-ulaval / libpointmatcher

An Iterative Closest Point (ICP) library for 2D and 3D mapping in Robotics
BSD 3-Clause "New" or "Revised" License
1.63k stars 549 forks source link

Segment fault when convert ros msg to point matcher #353

Closed LiShuaixin closed 5 years ago

LiShuaixin commented 5 years ago

Hi, I tried to testing segmap whose dependencies including libpointmatcher, but the system was killed by a segment fault caused at PointMatcher_ros::rosMsgToPointMatcherCloud<float>(cloud_msg_in);

I debugged the code and found the exact position of the fault is at line 159 in pointmatcher_ros/point_cloud.cpp: case PF::FLOAT32: { view(dim, ptId) = T(*reinterpret_cast<const float*>(fPtr));

It shows that the segment fault occurred when assigning vals to view, which is a Eigen::Block<Matrix>.

Moreover, I can successfully cout the vals of *reinterpret_cast<const float*>(fPtr) which means the accessing of the array is valid. And, it is valid at line 77 in the same .cpp file, when using cloud.getFeatureViewByName(it->name).setConstant(1); to assign vals to the matrix. But it is invalid if cout the matrix after assignment. It's so weird!

As far as I know, if the declaration of a dynamic matrix with known size or other fixed-size matrix, the assignment and accessing of the matrix should be legal. Is this the problem of the version of Eigen?

PhiBabin commented 5 years ago

The problem might be related to the version of eigen. Also, segmap is using an older version of libpointmatcher and libpointmatcher_ros (https://github.com/ethz-asl/ethzasl_icp_mapping/commit/a7d8ea9). I found the commit hash in this file. Maybe, updating this file, will update the dependencies? This is the list of changes made to libpointmatcher_ros, since commit a7d8ea9.

LiShuaixin commented 5 years ago

Hi @PhiBabin , thanks for your reply. Have you run segmap? which verision of eigen should I use to make the whole thing right? I'll also try to fix the issue using the latest version of eigen

PhiBabin commented 5 years ago

I have not run segmap. You simply have to make sure that every package is using the same Eigen version. So it's more about finding a different version of Eigen on your system, than trying to compile with the latest version of Eigen.

LiShuaixin commented 5 years ago

Hi, thanks for your suggestion. I use Eigen 3.2 and check every packages in the project to ensure the consistency of Eigen version and the issue was solved.