Those pits in the Eigen library (1)

I will open a topic here to record some of the big holes encountered in the process of using the Eigen library. Too much, it’s all bitter tears... well, the text begins


Continually updated……


Eigen memory alignment problem

When running the point cloud fusion experiment, I encountered an error when compiling:

/usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 16; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicU... " **** READ THIS WEB PAGE !!! ****"' failed.

Then I followed the prompts and checked the cause of the error in Eigen's document, saying it was related to Fixed-size vectorizable Eigen objects, but after debugging, I found that the error appeared in the readCameraTrajectory() function and was stored in poses.push_back(T) in the third This error will be reported when you are in a pose. And Eigen::Isometry3d checked, it should not belong to Fixed-size vectorizable Eigen objects. The magic is that when I delete the third frame of pose data and only read the first two frames of pose data, the code can be executed smoothly and a .pcd file is generated.

This problem plagued for two days,

Solution:

Add memory alignment parameters when initializing poses:

`vector<Eigen::Isometry3d, Eigen::aligned_allocator<Eigen::Isometry3d>> poses

And in the reference and definition of readCameraTrajectory() (the function that calls this parameter), the same changes are also made to poses.

Guess you like

Origin blog.csdn.net/weixin_44456692/article/details/105927155