introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.78k stars 786 forks source link

Standalone rtabmap crash due to g2o error #496

Closed m-pilia closed 4 years ago

m-pilia commented 4 years ago

I built rtabmap (standalone application, ROS-free) from source (with g2o and GTSAM integration) and tried to use it with a RealSense D435. Whenever the g2o optimiser is invoked (BA or loop closure), rtabmap crashes with the following error (always happens immediately when starting a mapping if g2o is used in the odometry):

[FATAL] (2020-01-22 09:23:34.101) OptimizerG2O.cpp:1615::optimizeBA() Condition (optimizer.verifyInformationMatrices()) not met!

The problem does not happen with other solvers, e.g. if I replace g2o with ceres or GTSAM in the config for BA and loop closure. I also did not encounter this error when using the binary .deb package from the ROS deb repository, so I assume it is not an issue with the camera. (I tried the binary distribution only as a ROS node and not using the standalone rtabmap, because the version distributed in the deb package is not built with librealsense2 integration).

How to reproduce

  1. Build the dependencies and rtabmap as described in the wiki (CMake output in the details section)
  2. Start rtabmap standalone GUI (run ./bin/rtabmap from the root folder of the git sources)
  3. Create new database from the toolbar button
  4. Set RealSense D435 source from the drop-down menu in the interface
  5. Click start

Result

Crash happens with log message:

[FATAL] (2020-01-22 09:23:34.101) OptimizerG2O.cpp:1615::optimizeBA() Condition (optimizer.verifyInformationMatrices()) not met!

Details

Output of cmake (click to expand) ``` -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/lib/ccache/cc -- Check for working C compiler: /usr/lib/ccache/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/lib/ccache/c++ -- Check for working CXX compiler: /usr/lib/ccache/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Checking for module 'eigen3' -- Found eigen3, version 3.2.92 -- Found eigen: /usr/include/eigen3 -- Checking for module 'libopenni' -- Found libopenni, version 1.5.4.0 -- Found openni: /usr/lib/libOpenNI.so -- Checking for module 'libopenni2' -- No package 'libopenni2' found -- Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS) -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake" but not all the files it references. -- Found libusb-1.0: /usr/include -- Checking for module 'flann' -- Found flann, version 1.8.4 -- Found Flann: /usr/lib/x86_64-linux-gnu/libflann_cpp_s.a -- Found qhull: /usr/lib/x86_64-linux-gnu/libqhull.so -- Checking for module 'libopenni2' -- No package 'libopenni2' found -- Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS) -- Found PCL_COMMON: /usr/lib/x86_64-linux-gnu/libpcl_common.so -- Found PCL_OCTREE: /usr/lib/x86_64-linux-gnu/libpcl_octree.so -- Found PCL_IO: /usr/lib/x86_64-linux-gnu/libpcl_io.so -- Found PCL_KDTREE: /usr/lib/x86_64-linux-gnu/libpcl_kdtree.so -- Found PCL_SEARCH: /usr/lib/x86_64-linux-gnu/libpcl_search.so -- Found PCL_SURFACE: /usr/lib/x86_64-linux-gnu/libpcl_surface.so -- Found PCL_FILTERS: /usr/lib/x86_64-linux-gnu/libpcl_filters.so -- Found PCL_FEATURES: /usr/lib/x86_64-linux-gnu/libpcl_features.so -- Found PCL_REGISTRATION: /usr/lib/x86_64-linux-gnu/libpcl_registration.so -- Found PCL_SAMPLE_CONSENSUS: /usr/lib/x86_64-linux-gnu/libpcl_sample_consensus.so -- Found PCL_GEOMETRY: /usr/include/pcl-1.7 -- Found PCL_SEGMENTATION: /usr/lib/x86_64-linux-gnu/libpcl_segmentation.so -- Found PCL_VISUALIZATION: /usr/lib/x86_64-linux-gnu/libpcl_visualization.so -- PCL definitions don't contain "-march=native", make sure all libraries using Eigen are also compiled without that flag to avoid some segmentation faults (with gdb referring to some Eigen functions). -- Found Sqlite3: /usr/include /usr/lib/x86_64-linux-gnu/libsqlite3.so -- Try OpenMP C flag = [-fopenmp] -- Performing Test OpenMP_FLAG_DETECTED -- Performing Test OpenMP_FLAG_DETECTED - Success -- Try OpenMP CXX flag = [-fopenmp] -- Performing Test OpenMP_FLAG_DETECTED -- Performing Test OpenMP_FLAG_DETECTED - Success -- Found OpenMP: -fopenmp -- Found OpenMP -- Found OpenCV: /usr/include/opencv;/usr/include -- Found PCL: /usr/include/pcl-1.7;/usr/include/eigen3;/usr/include;/usr/include/ni;/usr/include/vtk-6.2;/usr/include/freetype2;/usr/include/x86_64-linux-gnu/freetype2;/usr/include/x86_64-linux-gnu;/usr/include/jsoncpp;/usr/include/hdf5/openmpi;/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent;/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include;/usr/lib/openmpi/include;/usr/lib/openmpi/include/openmpi;/usr/include/libxml2;/usr/include/tcl;/usr/include/python2.7 -- Found ZLIB: /usr/include -- VTK_RENDERING_BACKEND=OpenGL -- Found Freenect: /usr/include -- Found DC1394: /usr/include/dc1394 -- Found CSPARSE: /usr/include/suitesparse CMake Warning at cmake_modules/FindG2O.cmake:122 (MESSAGE): Latest g2o version detected with c++11 interface (config file: /usr/local/include/g2o/config.h). Make sure g2o is built with "-DBUILD_WITH_MARCH_NATIVE=OFF" to avoid segmentation faults caused by Eigen. Call Stack (most recent call first): CMakeLists.txt:374 (FIND_PACKAGE) -- Found g2o: /usr/local/include;/usr/include/suitesparse;/usr/include/suitesparse -- Boost version: 1.58.0 -- Found the following Boost libraries: -- serialization -- system -- filesystem -- thread -- program_options -- date_time -- timer -- chrono -- regex -- atomic -- GTSAM include directory: /usr/local/lib/cmake/GTSAM/../../../include -- FlyCapture2_INCLUDE_DIR=FlyCapture2_INCLUDE_DIR-NOTFOUND -- FlyCapture2_LIBRARY=FlyCapture2_LIBRARY-NOTFOUND -- Triclops_INCLUDE_DIR=Triclops_INCLUDE_DIR-NOTFOUND -- Triclops_LIBRARY=Triclops_LIBRARY-NOTFOUND -- FlyCaptureBridge_LIBRARY=FlyCaptureBridge_LIBRARY-NOTFOUND -- Found cvsba: /usr/local/include -- Found libpointmatcher: /usr/local/include;/usr/include;/usr/include/eigen3;/usr/local/include -- Found RealSense2: -- Found required Ceres dependency: Eigen version 3.2.92 in /usr/include/eigen3 -- Found required Ceres dependency: glog -- Performing Test GFLAGS_IN_GOOGLE_NAMESPACE -- Performing Test GFLAGS_IN_GOOGLE_NAMESPACE - Success -- Found required Ceres dependency: gflags -- Found Ceres version: 1.12.0 installed in: /usr with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, CXSparse, SchurSpecializations, OpenMP] -- Architecture: x86_64 -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Found Pthreads -- -------------------------------------------- -- Info : -- Version : 0.19.6 -- CMAKE_INSTALL_PREFIX = /usr/local -- CMAKE_BUILD_TYPE = Release -- CMAKE_INSTALL_LIBDIR = lib -- BUILD_APP = ON -- BUILD_TOOLS = ON -- BUILD_EXAMPLES = ON -- BUILD_SHARED_LIBS = ON -- CMAKE_CXX_FLAGS = -fmessage-length=0 -fopenmp -std=c++11 -- FLANN_KDTREE_MEM_OPT = OFF -- PCL_DEFINITIONS = -DEIGEN_USE_NEW_STDVECTOR;-DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET;-DFLANN_STATIC;-Dqh_QHpointer -- PCL_VERSION = 1.7.2 -- -- Optional dependencies ('*' affects some default parameters) : -- *With OpenCV 2 nonfree module (SIFT/SURF) = NO (not found, License: BSD) -- With Qt5 = YES (License: Open Source or Commercial) -- With VTK 6.2 = YES (License: BSD) -- With external SQLite3 = YES (License: Public Domain) -- With ORB OcTree = YES (License: GPLv3) -- With Madgwick = YES (License: GPL) -- With FastCV = NO (FastCV not found) -- -- Solvers: -- With TORO = YES (License: Creative Commons [Attribution-NonCommercial-ShareAlike]) -- *With g2o = YES (License: BSD) -- *With GTSAM = YES (License: BSD) -- *With Ceres = YES (License: BSD) -- With VERTIGO = YES (License: GPLv3) -- With cvsba = YES (License: GPLv2) -- *With libpointmatcher = YES (License: BSD) -- -- Reconstruction Approaches: -- With OCTOMAP = NO (octomap not found) -- With CPUTSDF = NO (CPUTSDF not found) -- With OpenChisel = NO (open_chisel not found) -- With AliceVision = NO (WITH_ALICE_VISION=OFF) -- -- Camera Drivers: -- With Freenect = YES (License: Apache v2 and/or GPLv2) -- With OpenNI2 = NO (OpenNI2 not found) -- With Freenect2 = NO (libfreenect2 not found) -- With Kinect for Windows 2 = NO (Kinect for Windows 2 SDK not found) -- With Kinect for Azure = NO (Kinect for Azure SDK not found) -- With dc1394 = YES (License: LGPL) -- With FlyCapture2/Triclops = NO (Point Grey SDK not found) -- With ZED = NO (ZED sdk not found) -- With RealSense = NO (librealsense not found) -- With RealSense2 = YES (License: Apache-2) -- -- Odometry Approaches: -- With loam_velodyne = NO (loam_velodyne not found) -- With libfovis = NO (libfovis not found) -- With libviso2 = NO (libviso2 not found) -- With dvo_core = NO (dvo_core not found) -- With okvis = NO (okvis not found) -- With msckf_vio = NO (WITH_MSCKF_VIO=OFF) -- With VINS-Fusion = NO (VINS-Fusion not found) -- With ORB_SLAM2 = NO (WITH_G2O should be OFF as ORB_SLAM2 uses its own g2o version) -- -------------------------------------------- -- Configuring done -- Generating done -- Build files have been written to: /home/martino/Code/rtabmap/build2 ```
Output of rtabmap --version (click to expand) ``` $ ./rtabmap --version RTAB-Map: 0.19.6 PCL: 1.7.2 With VTK: 6.2.0 OpenCV: 2.4.9.1 With OpenCV nonfree: false With ORB OcTree: true With FastCV: false With Madgwick: true With TORO: true With g2o: true With GTSAM: true With Vertigo: true With CVSBA: true With Ceres: true With OpenNI2: false With Freenect: true With Freenect2: false With K4W2: false With DC1394: true With FlyCapture2: false With ZED: false With RealSense: false With RealSense SLAM: false With RealSense2: true With libpointmatcher: true With octomap: false With cpu-tsdf: false With open chisel: false With Alice Vision: false With LOAM: false With FOVIS: false With Viso2: false With DVO: false With ORB_SLAM2: false With OKVIS: false With MSCKF_VIO: false With VINS-Fusion: false ```
matlabbe commented 4 years ago

g2o is built from source, I generally test with libg2o installed from ros (ros-kinetic-libg2o for 16.04), maybe there is a difference. Here what is said on g2o documentation:

    /**
     * verify that all the information of the edges are semi positive definite, i.e.,
     * all Eigenvalues are >= 0.
     * @param verbose output edges with not PSD information matrix on cerr
     * @return true if all edges have PSD information matrix
     */
    bool verifyInformationMatrices(bool verbose = false) const;

I tried on an Ubuntu 16.04 computer (kernel 4.4.0) with realsense 2.25.0, D435i and latest g2o built from source. I don't have problems with default parameters with g2o as the graph optimization approach. Loop closures are accepted as expected without crashing.

It could be an Eigen problem, do you have multiple Eigen libraries installed? If g2o is built against an Eigen version and rtabmap with another it could create bugs like that. You may try building against g2o binaries instead of source to see if it could be a dependency problem.

cheers, Mathieu

m-pilia commented 4 years ago

Hi Mathieu, thanks for the reply!

I built all packages against the system version of Eigen, but it may be possible that I made some mistake in the configuration. Will try against a binary version of g2o, since I also had other issues with g2o built from source in other tools.

I would close this issue since I will not be able to follow up. Thanks for the help!