jingpang / LearnVIORB

Other
818 stars 451 forks source link

segfault when relocalization #71

Closed ns15417 closed 4 years ago

ns15417 commented 4 years ago

I run the code on Ubuntu16.04 using realsensed435i. It is ok to init VIO and tracking mono, but so mething wired always happen when LOST, the most common one is segment fault after running Relocalization() and got someKFs pushed into mv20FramesReloc, I debug it using gbd and got the log like below: `Finished copy IMU data ----------------------------TRacking with State: 3 --------------------------- Relocalization.... got 1vpCandidateKFs inside Relocalization() Mono IMU Frame constructor... Finished copy IMU data ----------------------------TRacking with State: 3 --------------------------- Relocalization.... got 2vpCandidateKFs inside Relocalization() Relocalized. id: 1514 Finished tracking local map.... mstate =OK start to push finished push and current mv20FramesReloc size: 1 updated motion model.... cleaned vo matches and temporal mappoints Mono IMU Frame constructor... Finished copy IMU data ----------------------------TRacking with State: 2 --------------------------- TRacking with ref KF Finished tracking local map.... mstate =OK

Thread 1 "rgb_imu" received signal SIGSEGV, Segmentation fault. 0x00007ffff7b81960 in Sophus::SO3::operator=(Sophus::SO3 const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so (gdb) bt

0 0x00007ffff7b81960 in Sophus::SO3::operator=(Sophus::SO3 const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

1 0x00007ffff7b4a9ae in ORB_SLAM2::Frame::Frame(ORB_SLAM2::Frame const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

2 0x00007ffff7a5dac0 in void std::vector<ORB_SLAM2::Frame, std::allocator >::_M_emplace_back_aux<ORB_SLAM2::Frame const&>(ORB_SLAM2::Frame const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

3 0x00007ffff7a58ba6 in ORB_SLAM2::Tracking::Track() () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

4 0x00007ffff7a58e99 in ORB_SLAM2::Tracking::GrabImageMonoVI(cv::Mat const&, std::vector<ORB_SLAM2::IMUData, std::allocator > const&, double const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

5 0x00007ffff7a3e088 in ORB_SLAM2::System::TrackMonoVI(cv::Mat const&, std::vector<ORB_SLAM2::IMUData, std::allocator > const&, double const&) () from /home/shinan/Project/LearnVIORB/lib/libORB_SLAM2.so

6 0x0000000000408065 in main ()`

Do you have any idea how this bug happen? normally it happens when i have 1 keyframe in mv20FramesReloc, but sometimes happens when 8 keyframes pushed into mv20FramesReloc. it should be something wrong here https://github.com/jingpang/LearnVIORB/blob/RT/src/Tracking.cc cuz it construct a new Frame and pushed into vector, but i have no idea why it is linked to SO3, how this happen?

Thanks Very much for your atterntion!!

ns15417 commented 4 years ago

I fixed this bug by add EIGEN_MAKE_ALIGNED_OPERATOR_NEW inside the class Frame and change the vector mv20FramesReloc from vector to vector<Frame,Eigen::aligned_allocator> . if you are looking for explaination in Chinese i would rec this blog https://blog.csdn.net/rs_huangzs/article/details/50574141, or in English the Eigen official web works: http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html