slam14讲-ch5问题记录-" **** READ THIS WEB PAGE !!! ****"’ failed
问题描述
Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 16; int MatrixOrArrayOptions = 0]: Assertion `(internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
问题原因
STL Containers or manual memory allocation
具体代码
vector<Eigen::Isometry3d> poses;//camera poses
解决方法
#include<Eigen/StdVector>
vector<Eigen::Isometry3d,Eigen::aligned_allocator<Eigen::Isometry3d>> poses;//camera poses
分配空间
本文详细介绍了在使用Eigen库时遇到的内存对齐问题,即Eigen库在处理某些STL容器时发生的assertion失败。问题出现在`vector<Eigen::Isometry3d>`的实例上,由于默认的内存分配不满足Eigen的对齐要求,导致程序崩溃。为解决此问题,文章提出使用`aligned_allocator`模板参数来确保内存分配符合Eigen的对齐规定,修改后的代码为`vector<Eigen::Isometry3d, Eigen::aligned_allocator<Eigen::Isometry3d>> poses`。通过这种方式,可以避免内存对齐错误,保证代码的正确运行。
1607

被折叠的 条评论
为什么被折叠?



