Open AnGPU opened 6 years ago
Hi,
You should not have to modify the cmake files. When using ORB_SLAM2, you cannot link on g2o installed in /usr/local. When doing "cmake WITH_G2O=OFF WITH_ORB_SLAM2=ON ..", g2o version in ORB_SLAM2 (which is not compatible with g2o version installed by source) will be used instead. On runtime, you should make sure to add the path of g2o library built in ORB_SLAM2 library to LD_LIBRARY_PATH so that libg2o.so can be found:
rtabmap: error while loading shared libraries: libg2o.so: cannot open shared object file: No such file or directory
This is what I do in my .bashrc file:
$ export LD_LIBRARY_PATH=/home/mathieu/workspace/ORB_SLAM2/lib:/home/mathieu/workspace/ORB_SLAM2/Thirdparty/g2o/lib:/home/mathieu/workspace/ORB_SLAM2/Thirdparty/DBoW2/lib:$LD_LIBRARY_PATH
cheers, Mathieu
Thanks! Now it runs but sends an Error message related with this part of the OdometryORBSLAM2.cpp code. "if(data.imageRaw().empty() || data.imageRaw().rows != data.depthOrRightRaw().rows || data.imageRaw().cols != data.depthOrRightRaw().cols) { UERROR("Not supported input!"); return t; }" "[ERROR] (2018-06-19 11:40:53.312) OdometryORBSLAM2.cpp:862::computeTransform() Not supported input!" Should I open another issue and close this or ask here directly? I supposed it could be a problem from the source but I've never seen this kind of problem working with the configuration of the realsense zr300.
In the commit above, I added an option to RealSense driver to scale depth image to RGB size so that both images have the same size, which is required for ORB_SLAM2. The option is in Preferences->Source, then under RealSense group box: "Depth image scaled to RGB image size.". You can give a try.
It runs for several seconds and then segmentation fault. trying with gdb shows this:
Thread 21 "rtabmap" received signal SIGSEGV, Segmentation fault. [Changing to Thread 0x7fff92003700 (LWP 9958)] 0x00007fffe70a7a15 in ORB_SLAM2::Optimizer::PoseOptimization(ORB_SLAM2::Frame*) () from /home/antonioguerrero/ORB_SLAM2/lib/libORB_SLAM2.so
You can do "bt" in gdb to get a backtrace. However, the error seems coming from ORB_SLAM2 library. I don't have this error on my system though, I can run it for minutes without crashing. Can you show how did you build ORB_SLAM2 and rtabmap (cmake command lines and cmake status)? Are you using PCL 1.8 as it may be an Eigen problem (PCL 1.8 is built with -march=native
)? Can you also show output of ldd rtabmap
?
cheers, Mathieu
(gdb) bt
from /home/antonioguerrero/ORB_SLAM2/lib/libORB_SLAM2.so
from /usr/local/lib/librtabmap_core.so.0.17
from /usr/local/lib/librtabmap_core.so.0.17
from /usr/local/lib/librtabmap_core.so.0.17
from /usr/local/lib/librtabmap_core.so.0.17
at pthread_create.c:333
RTABMAP
cmake -DWITH_G2O=OFF ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/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/bin/c++
-- Check for working CXX compiler: /usr/bin/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.3.90
-- 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 imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include:
-- 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).
-- 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: /opt/ros/kinetic/include/opencv-3.3.1-dev;/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv
-- Found PCL: /usr/include/pcl-1.7;/usr/include/eigen3;/usr/include;/usr/include/ni;/usr/include/vtk-6.2;/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/x86_64-linux-gnu;/usr/include/freetype2;/usr/include/x86_64-linux-gnu/freetype2;/usr/include/jsoncpp;/usr/include/python2.7;/usr/include/tcl
-- Found ZLIB: /usr/include
-- Found DC1394: /usr/include/dc1394
-- Found RealSense: /opt/ros/kinetic/include
-- Found RealSenseSlam: /opt/ros/kinetic/include
-- Found RealSense2:
-- Found octomap 1.8.1: /opt/ros/kinetic/include
-- Found ORB_SLAM2: /home/antonioguerrero/ORB_SLAM2/include;/home/antonioguerrero/ORB_SLAM2/Thirdparty/g2o;/home/antonioguerrero/ORB_SLAM2
-- Found Pangolin: /usr/local/lib/cmake/Pangolin/../../../include;/usr/include;/usr/include;/usr/include;/home/antonioguerrero/eigen
-- 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.17.3 -- 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 -- PCL_DEFINITIONS = -DEIGEN_USE_NEW_STDVECTOR;-DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET;-DFLANN_STATIC;-Dqh_QHpointer -- With OpenCV 3 xfeatures2d module (SIFT/SURF/BRIEF/FREAK) = YES (License: Non commercial) -- With Freenect = NO (libfreenect not found) -- 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 dc1394 = YES (License: LGPL) -- With FlyCapture2/Triclops = NO (Point Grey SDK not found) -- With TORO = YES (License: Creative Commons [Attribution-NonCommercial-ShareAlike]) -- With g2o = NO (WITH_G2O=OFF) -- With GTSAM = NO (GTSAM not found) -- With VERTIGO = NO (GTSAM or g2o required) -- With cvsba = NO (cvsba not found) -- With libpointmatcher = NO (libpointmatcher not found) -- With ZED = NO (ZED sdk not found) -- With RealSense = YES (License: Apache-2) -- With RealSenseSlam = YES -- With RealSense2 = YES (License: Apache-2) -- With OCTOMAP = YES (License: BSD) -- With CPUTSDF = NO (CPUTSDF not found) -- With OpenChisel = NO (open_chisel 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 ORB_SLAM2 = YES (License: GPLv3) -- With Qt5 = YES (License: Open Source or Commercial)
-- Configuring done -- Generating done
For ORBSLAM2 I applied this changes from the usual installation to reduce significantly the reading of the vocabulary in embedded platforms https://github.com/raulmur/ORB_SLAM2/pull/21 I'm using the library which comes with ros kinetic -> libpcl1.7 ldd: ./rtabmap: it's not a regular file (translation from spanish warn)
I just checked the differences in my clone of ORB_SLAM2 code, and I removed-march=native
flags (as PCL on Ubuntu 16.04 is not built with this flag):
~/workspace/ORB_SLAM2$ git diff Thirdparty/g2o/CMakeLists.txt
diff --git a/Thirdparty/g2o/CMakeLists.txt b/Thirdparty/g2o/CMakeLists.txt
index 620e688..ba8396c 100644
--- a/Thirdparty/g2o/CMakeLists.txt
+++ b/Thirdparty/g2o/CMakeLists.txt
@@ -54,8 +54,8 @@ IF(OPENMP_FOUND AND G2O_USE_OPENMP)
ENDIF(OPENMP_FOUND AND G2O_USE_OPENMP)
# Compiler specific options for gcc
-SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native")
-SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native")
+SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ")
+SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
# activate warnings !!!
SET(g2o_C_FLAGS "${g2o_C_FLAGS} -Wall -W")
~/workspace/ORB_SLAM2$ git diff Thirdparty/DBoW2/CMakeLists.txt
diff --git a/Thirdparty/DBoW2/CMakeLists.txt b/Thirdparty/DBoW2/CMakeLists.txt
index 0eb5126..db34af2 100644
--- a/Thirdparty/DBoW2/CMakeLists.txt
+++ b/Thirdparty/DBoW2/CMakeLists.txt
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(DBoW2)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall ")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
set(HDRS_DBOW2
DBoW2/BowVector.h
~/workspace/ORB_SLAM2$ git diff CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08a8af4..8190289 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,8 @@ ENDIF()
MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall ")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
You may give a try.
Thanks That seemed to be the problem and now I can run it perfectly.
Hi Mathieu I'm sorry to have to reopen this thread but trying to reinstall the orb slam2 function, after searching every file from rtabmap and removing it, I can't because of this errors at the end of the make -j4
in the process modifying the files from the comitt with this steps git clone https://github.com/introlab/rtabmap.git rtabmap cd rtabmap/build
replacing the files: corelib/include/rtabmap/core/CameraRGBD.h corelib/src/CameraRGBD.cpp corelib/src/OdometryORBSLAM2.cpp guilib/src/PreferencesDialog.cpp guilib/src/ui/preferencesDialog.ui
cmake -DWITH_G2O=OFF .. make -j4 sudo make install
It is strange, these functions should be in PreferencesDialog.cpp: https://github.com/introlab/rtabmap/blob/89a0eb506b7e45464d76248bf778bf13646fc5cb/guilib/src/PreferencesDialog.cpp#L5338-L5341 https://github.com/introlab/rtabmap/blob/89a0eb506b7e45464d76248bf778bf13646fc5cb/guilib/src/PreferencesDialog.cpp#L4416-L4419
I don't know. I don't remember to change more than what was made in the commit and don't open it again after that. Anyway I copy the file again from here and now it works. Thanks for pointing the file, I didn't know where to look for.
I'm working in the way to add the commit raulmur/ORB_SLAM2#21 to reduce significantly the time of vocabulary reading within a binary file instead of the txt one which is determining to test this into a embedded system. So I will let this issue open if theres's no inconvenience.
I tried to compile rtab-map with orb-slam2, but a segmentation fault occurred. The gdb debugging information is as follows: Thread 35 "rtabmap" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fff48898700 (LWP 23066)] 0x00007ffff71c4430 in g2o::BaseBinaryEdge<6, g2o::SE3Quat, g2o::VertexSE3Expmap, g2o::VertexSE3Expmap>::linearizeOplus() () from /home/tao/Documents/RTAB-Map/rtabmap/bin/librtabmap_core.so.0.19 (gdb) BT
from /home/tao/Documents/RTAB-Map/rtabmap/bin/librtabmap_core.so.0.19
() from /home/tao/Documents/RTAB-Map/rtabmap/bin/librtabmap_core.so.0.19
from /home/tao/slam/ORB_SLAM2/Thirdparty/g2o/lib/libg2o.so
from /home/tao/slam/ORB_SLAM2/Thirdparty/g2o/lib/libg2o.so
from /home/tao/Documents/RTAB-Map/rtabmap/bin/librtabmap_core.so.0.19
from /home/tao/Documents/RTAB-Map/rtabmap/bin/librtabmap_core.so.0.19
I don't know where to find the problem
Hi Mathieu after several attempts following this http://official-rtab-map-forum.206.s1.nabble.com/How-to-use-ORB-SLAM2-library-in-rtabmap-td4230.html I managed to get the orb2 slam to be recognized in the cmake but after continuing the installation, trying to run rtabmap to set the odometry strategy I got this before anything works: "rtabmap: error while loading shared libraries: libg2o.so: cannot open shared object file: No such file or directory" but it is in the place pointed by the findORB_SLAM2.cmake I found almost similar situation with another libraries here and try sudo ldconfig but didn't work. I try to run in gdb with bt as seen in other issues if I could find more information but: (gdb) run Starting program: /usr/local/bin/rtabmap /usr/local/bin/rtabmap: error while loading shared libraries: libg2o.so: cannot open shared object file: No such file or directory [Inferior 1 (process 10258) exited with code 0177] (gdb) bt No stack. System: ubuntu 16.04 rtabmap: standalone 0.17.2
**edit* next step changing line 13 in findORB_SLAM2.cmake to: find_library(g2o_LIBRARY NAMES libg2o.so** PATHS $ENV{ORB_SLAM2_ROOT_DIR}/Thirdparty/g2o/lib) that library is being recognized but in the make step, after relink types_sba.h,types_six_dof_expmap.h and linear_solver_eigen.h to the right path in lines 73, 74, 75 respectively in OptimizerG2O.cpp, crash at 6% within building:
[ 6%] Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/OptimizerG2O.cpp.o /home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp: In member function ‘virtual bool rtabmap::EdgeSE3Expmap::setMeasurementData(const double)’: /home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:794:24: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive] Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:794:37: error: template argument 1 is invalid
Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:794:42: error: invalid conversion from ‘const double ’ to ‘int’ [-fpermissive]
Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:795:32: error: no matching function for call to ‘g2o::SE3Quat::fromVector(int&)’
_measurement.fromVector(v);
^
In file included from /usr/local/include/g2o/types/sba/sbacam.h:46:0,
from /usr/local/include/g2o/types/sba/types_sba.h:33,
from /home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:73:
/usr/local/include/g2o/types/slam3d/se3quat.h:145:19: note: candidate: void g2o::SE3Quat::fromVector(const Vector7&)
inline void fromVector(const Vector7& v){
^
/usr/local/include/g2o/types/slam3d/se3quat.h:145:19: note: no known conversion for argument 1 from ‘int’ to ‘const Vector7& {aka const Eigen::Matrix<double, 7, 1, 0, 7, 1>&}’
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp: In member function ‘virtual bool rtabmap::EdgeSE3Expmap::getMeasurementData(double) const’:
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:801:18: error: ‘Vector7d’ is not a member of ‘g2o’
Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:801:18: error: ‘Vector7d’ is not a member of ‘g2o’
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:801:31: error: template argument 1 is invalid
Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:801:36: error: invalid conversion from ‘double ’ to ‘int’ [-fpermissive]
Eigen::Map v(d);
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:802:9: error: cannot convert ‘g2o::Vector7 {aka Eigen::Matrix<double, 7, 1, 0, 7, 1>}’ to ‘int’ in assignment
v = measurement.toVector();
^
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp: In member function ‘virtual std::map<int, rtabmap::Transform> rtabmap::OptimizerG2O::optimizeBA(int, const std::map<int, rtabmap::Transform>&, const std::multimap<int, rtabmap::Link>&, const std::map<int, rtabmap::CameraModel>&, std::map<int, cv::Point3 >&, const std::map<int, std::map<int, cv::Point3_ > >&, std::set)’:
/home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:907:104: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::LinearSolverType&)’
w g2o::OptimizationAlgorithmLevenberg(new g2o::BlockSolver_6_3(linearSolver)));
^
In file included from /usr/local/include/g2o/core/block_solver.h:199:0,
from /home/antonioguerrero/rtabmap/corelib/src/OptimizerG2O.cpp:43:
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: candidate: g2o::BlockSolver::BlockSolver(std::unique_ptr) [with Traits = g2o::BlockSolverTraits<6, 3>; typename Traits::LinearSolverType = g2o::LinearSolver<Eigen::Matrix<double, 6, 6, 0> >]
BlockSolver::BlockSolver(std::unique_ptr linearSolver
^
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: no known conversion for argument 1 from ‘g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::LinearSolverType {aka g2o::LinearSolver<Eigen::Matrix<double, 6, 6, 0> >}’ to ‘std::unique_ptr<g2o::LinearSolver<Eigen::Matrix<double, 6, 6, 0> >, std::default_delete<g2o::LinearSolver<Eigen::Matrix<double, 6, 6, 0> > > >’
corelib/src/CMakeFiles/rtabmap_core.dir/build.make:1027: fallo en las instrucciones para el objetivo 'corelib/src/CMakeFiles/rtabmap_core.dir/OptimizerG2O.cpp.o'
**edit2*** to solve problems of OptimizerG2O.cpp from 794 to 802 correct the code this way: Eigen::Map -> Eigen::Map
still workin on problem line 907