Jiankai-Sun / ORB_SLAM2

ORB_SLAM2 with map load/save function
GNU General Public License v3.0
82 stars 37 forks source link

Saving map and loading the data #1

Open hesamira opened 6 years ago

hesamira commented 6 years ago

Dear @Jiankai-Sun,

Hello, I have used your code for ORB_SLAM2. Jiankai-Sun, thanks for your code. When I have compiled your code, I have faced error:

sami@sami:~/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build$ make -j -- Found PythonInterp: /usr/bin/python (found version "2.7.6") [rosbuild] Building package ORB_SLAM2 [rosbuild] Cached build flags older than manifests; calling rospack to get flags -- Using CATKIN_DEVEL_PREFIX: /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel -- Using CMAKE_PREFIX_PATH: /home/sami/orbslam2_catkin_ws/devel;/opt/ros/indigo -- This workspace overlays: /home/sami/orbslam2_catkin_ws/devel;/opt/ros/indigo -- Using PYTHON_EXECUTABLE: /usr/bin/python -- Using Debian Python package layout -- Using empy: /usr/bin/empy -- Using CATKIN_ENABLE_TESTING: ON -- Skip enable_testing() for dry packages -- Using CATKIN_TEST_RESULTS_DIR: /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/test_results -- Looking for include file pthread.h -- Looking for include file pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found gtest sources under '/usr/src/gtest': gtests will be built -- Using Python nosetests: /usr/bin/nosetests-2.7 -- catkin 0.6.19 [rosbuild] using multiarch 'x86_64-linux-gnu' for finding Boost -- Using these message generators: gencpp;genlisp;genpy [rosbuild] Including /opt/ros/indigo/share/roslisp/rosbuild/roslisp.cmake [rosbuild] Including /opt/ros/indigo/share/roscpp/rosbuild/roscpp.cmake [rosbuild] Including /opt/ros/indigo/share/rospy/rosbuild/rospy.cmake Build type: RelWithDebInfo -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Using flag -std=c++11. -- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.1.0") -- Boost version: 1.54.0 -- Found the following Boost libraries: -- system -- Configuring done -- Generating done -- Build files have been written to: /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build Scanning dependencies of target rospack_genmsg_libexe [ 0%] Built target rospack_genmsg_libexe Scanning dependencies of target rosbuild_precompile [ 0%] Built target rosbuild_precompile Scanning dependencies of target Mono Scanning dependencies of target MonoAR Scanning dependencies of target RGBD Scanning dependencies of target Stereo [ 20%] [ 40%] [ 60%] Building CXX object CMakeFiles/Mono.dir/src/ros_mono.cc.o Building CXX object CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o Building CXX object CMakeFiles/Stereo.dir/src/ros_stereo.cc.o [ 80%] [100%] Building CXX object CMakeFiles/MonoAR.dir/src/AR/ros_mono_ar.cc.o Building CXX object CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o Linking CXX executable ../Mono Linking CXX executable ../RGBD Linking CXX executable ../Stereo CMakeFiles/Mono.dir/src/ros_mono.cc.o: In function main': /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc:59: undefined reference toORB_SLAM2::System::System(std::string const&, std::string const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: In function main': /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_stereo.cc:64: undefined reference toORB_SLAM2::System::System(std::string const&, std::string const&, ORB_SLAM2::System::eSensor, bool)' CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: In function main': /home/sami/orbslam2_catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_rgbd.cc:62: undefined reference toORB_SLAM2::System::System(std::string const&, std::string const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status collect2: error: ld returned 1 exit status make[2]: [../Mono] Error 1 make[2]: [../RGBD] Error 1 make[2]: [../Stereo] Error 1 make[1]: [CMakeFiles/Mono.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... make[1]: [CMakeFiles/RGBD.dir/all] Error 2 make[1]: [CMakeFiles/Stereo.dir/all] Error 2 make[1]: [CMakeFiles/MonoAR.dir/all] Error 2 make: *** [all] Error 2

I have used Ubuntu 14.04, ROS indigo and OpenCV 2.4.13. I also have tested your code with Ubuntu 16.04, ROS Kinetic and OpenCV 2.4.13.

I think that there is a problem in ros_mono.cc or system.cc file. Is it correct? I do not know where is the problem, exactly. I have tried a lot. your answer is very important to me. I need to save map and the load data.

Please guide me. Thanks.

ghost commented 6 years ago

Hi, same problem happens on me. (Ubuntu 16.04 + ROS Kinect) Has anybody solved this issue ?

xxx@xxx-PC:~/ORB_SLAM2$./build_ros.sh ... [ 44%] Linking CXX executable ../MonoAR CMakeFiles/Mono.dir/src/ros_mono.cc.o: In function main': ros_mono.cc:(.text.startup+0x104): undefined reference toORB_SLAM2::System::System(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status CMakeFiles/Mono.dir/build.make:214: recipe for target '../Mono' failed make[2]: [../Mono] Error 1 CMakeFiles/Makefile2:718: recipe for target 'CMakeFiles/Mono.dir/all' failed make[1]: [CMakeFiles/Mono.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: In function main': ros_rgbd.cc:(.text.startup+0x111): undefined reference toORB_SLAM2::System::System(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status CMakeFiles/RGBD.dir/build.make:214: recipe for target '../RGBD' failed make[2]: [../RGBD] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: [CMakeFiles/RGBD.dir/all] Error 2 CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: In function main': ros_stereo.cc:(.text.startup+0xaa8): undefined reference toORB_SLAM2::System::System(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status CMakeFiles/Stereo.dir/build.make:214: recipe for target '../Stereo' failed make[2]: [../Stereo] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: [CMakeFiles/Stereo.dir/all] Error 2 CMakeFiles/MonoAR.dir/src/AR/ros_mono_ar.cc.o: In function main': ros_mono_ar.cc:(.text.startup+0xbfc): undefined reference toORB_SLAM2::System::System(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, ORB_SLAM2::System::eSensor, bool)' collect2: error: ld returned 1 exit status CMakeFiles/MonoAR.dir/build.make:297: recipe for target '../MonoAR' failed make[2]: [../MonoAR] Error 1 CMakeFiles/Makefile2:820: recipe for target 'CMakeFiles/MonoAR.dir/all' failed make[1]: [CMakeFiles/MonoAR.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: [all] Error 2

ghost commented 6 years ago

Hi, I found an error and solved like this. I hope it would help for anybody who has the same problem.

1) ~/ORB_SLAM2/build_ros.h - line 6 --cmake .. -DROS_BUILD_TYPE=Release ++cmake .. -DROS_BUILD_TYPE=Release -DUSE_MAP_SAVE_LOAD=1

2) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeLists.txt - line 60 ++if(USE_MAP_SAVE_LOAD) ++ ADD_DEFINITIONS(-DFUNC_MAP_SAVE_LOAD) ++endif()

3) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc - line 59 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true); ++#endif

4) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_stereo.cc - line 64 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true); ++#endif

5) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_rgbd.cc - line 62 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true); ++#endif

6) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ros_mono_ar.cc - line 70 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false,false); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false); ++#endif

gnykumar commented 5 years ago

Hi, I found an error and solved like this. I hope it would help for anybody who has the same problem.

  1. ~/ORB_SLAM2/build_ros.h - line 6 --cmake .. -DROS_BUILD_TYPE=Release ++cmake .. -DROS_BUILD_TYPE=Release -DUSE_MAP_SAVE_LOAD=1
  2. ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeLists.txt - line 60 ++if(USE_MAP_SAVE_LOAD) ++ ADD_DEFINITIONS(-DFUNC_MAP_SAVE_LOAD) ++endif()
  3. ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc - line 59 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true); ++#endif
  4. ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_stereo.cc - line 64 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::STEREO,true); ++#endif
  5. ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_rgbd.cc - line 62 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true,true); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::RGBD,true); ++#endif
  6. ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ros_mono_ar.cc - line 70 -- ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false); ++#ifdef FUNC_MAP_SAVE_LOAD ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false,false); ++#else ++ ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false); ++#endif

@jasonoh231

Thank you

This solution worked for me!