tum-vision / lsd_slam

LSD-SLAM
GNU General Public License v3.0
2.6k stars 1.23k forks source link

Link libg2o correctly #227

Open romdos opened 7 years ago

romdos commented 7 years ago

Hi! I try to install lsd_slam via catkin_make in ros_workspace, but there are some errors connected with libg2o. I installed libg2o previously and it is located in /opt/ros/kinetic/share/cmake_modules/cmake/Modules. But when I run catkin_make in catkin workspace there is next error. (I use Ubuntu 16.04 and ros kinetic)

...
Scanning dependencies of target lsdslam
[ 37%] Building CXX object lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/main_viewer.o
[ 38%] Building CXX object lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/PointCloudViewer.o
[ 42%] Building CXX object lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/src/DataStructures/Frame.cpp.o
[ 42%] Building CXX object lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/src/DataStructures/FramePoseStruct.cpp.o
In file included from /home/roman/ros_workspace/catkin/src/lsd_slam/lsd_slam_core/src/DataStructures/FramePoseStruct.h:23:0,
                 from /home/roman/ros_workspace/catkin/src/lsd_slam/lsd_slam_core/src/DataStructures/FramePoseStruct.cpp:22:
/home/roman/ros_workspace/catkin/src/lsd_slam/lsd_slam_core/src/GlobalMapping/g2oTypeSim3Sophus.h:24:59: fatal error: /opt/ros/kinetic/include/g2o/core/base_vertex.h: No such file or directory

Any help!

af-silva commented 7 years ago

Hi,

Put this in your cmake folder located in the lsd_slam_core package and then in the CMakeLists add this line include(cmake/FindG2O.cmake) and try again to compile the project.

betsyngten commented 6 years ago

the link seems to be dead also i found the include(cmake/FindG20.make) in the CMakeLists already maybe they patched it?

I still get the same error is there another possibility to fix this?

af-silva commented 6 years ago

Maybe I don't know, you can find it here link. Make sure the file is there and that the main CMakeList file has it (the include). If you want, you can go to my fork and see, the code there is being compiled on Ubuntu 16.04 and with ROS Indigo and it works ok.

betsyngten commented 5 years ago

ok lets start from the beginning im on an Ubuntu 14.4 virutal machine on ROS Development studios and I get the error:

/home/user/simulation_ws/src/lsd_slam/lsd_slam_core/src/GlobalMapping/g2oTypeSim3Sophus.h:24:34: fatal error: g2o/core/base_vertex.h: No such file or directory compilation terminated.

I have tried to go to src/lsd_slam_core/cmake/FindG20.make I basically deleted the old file and copied your file in it. but I still get the same error message.

i looked in src/lsd_slam_core/CMakeLists.txt and starting in line 23 there is:

find_package(Eigen REQUIRED) find_package(X11 REQUIRED) include(cmake/FindG2O.cmake) include(cmake/FindSuiteParse.cmake)

so the include is already there

Maybe im getting something wrong so here is the complete error output:

In file included from /home/user/simulation_ws/src/lsd_slam/lsd_slam_core/src/DataStructures/FramePoseStruct.h:23:0, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_core/src/DataStructures/Frame.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_core/src/DataStructures/Frame.cpp:21: /home/user/simulation_ws/src/lsd_slam/lsd_slam_core/src/GlobalMapping/g2oTypeSim3Sophus.h:24:34: fatal error: g2o/core/base_vertex.h: No such file or directory compilation terminated. lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/build.make:62: recipe for target 'lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/src/DataStructures/Frame.cpp.o' failed make[2]: [lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/src/DataStructures/Frame.cpp.o] Error 1 CMakeFiles/Makefile2:4375: recipe for target 'lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/all' failed make[1]: [lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... [ 36%] Building CXX object lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/PointCloudViewer.o In file included from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.cpp:22:0: /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h: In member function ‘std::__cxx11::string AnimationObject::toString()’: /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h:136:26: error: invalid initialization of non-const reference of type ‘qreal& {aka double&}’ from an rvalue of type ‘qreal {aka double}’ frame.getPosition(x,y,z); ^ In file included from /usr/include/QGLViewer/keyFrameInterpolator.h:31:0, from /usr/include/QGLViewer/camera.h:26, from /usr/include/QGLViewer/qglviewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.cpp:22: /usr/include/QGLViewer/frame.h:188:7: note: initializing argument 1 of ‘void qglviewer::Frame::getPosition(qreal&, qreal&, qreal&) const’ void getPosition(qreal& x, qreal& y, qreal& z) const; ^ In file included from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/main_viewer.cpp:25:0: /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h: In member function ‘std::__cxx11::string AnimationObject::toString()’: /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h:136:26: error: invalid initialization of non-const reference of type ‘qreal& {aka double&}’ from an rvalue of type ‘qreal {aka double}’ frame.getPosition(x,y,z); ^ In file included from /usr/include/QGLViewer/keyFrameInterpolator.h:31:0, from /usr/include/QGLViewer/camera.h:26, from /usr/include/QGLViewer/qglviewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/main_viewer.cpp:25: /usr/include/QGLViewer/frame.h:188:7: note: initializing argument 1 of ‘void qglviewer::Frame::getPosition(qreal&, qreal&, qreal&) const’ void getPosition(qreal& x, qreal& y, qreal& z) const; ^ /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.cpp: In member function ‘virtual void PointCloudViewer::keyPressEvent(QKeyEvent)’: /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.cpp:327:44: error: invalid initialization of non-const reference of type ‘qreal& {aka double&}’ from an rvalue of type ‘qreal {aka double}’ camera()->frame()->getPosition(x,y,z); ^ In file included from /usr/include/QGLViewer/keyFrameInterpolator.h:31:0, from /usr/include/QGLViewer/camera.h:26, from /usr/include/QGLViewer/qglviewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.h:26, from /home/user/simulation_ws/src/lsd_slam/lsd_slam_viewer/src/PointCloudViewer.cpp:22: /usr/include/QGLViewer/frame.h:188:7: note: initializing argument 1 of ‘void qglviewer::Frame::getPosition(qreal&, qreal&, qreal&) const’ void getPosition(qreal& x, qreal& y, qreal& z) const; ^ lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/build.make:86: recipe for target 'lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/PointCloudViewer.o' failed make[2]: ** [lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/PointCloudViewer.o] Error 1 make[2]: Waiting for unfinished jobs.... lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/build.make:62: recipe for target 'lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/main_viewer.o' failed make[2]: [lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/src/main_viewer.o] Error 1 CMakeFiles/Makefile2:4221: recipe for target 'lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/all' failed make[1]: [lsd_slam/lsd_slam_viewer/CMakeFiles/viewer.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j2 -l2" failed

Please help me I cannot find a lot of possibilities to fix this.

Also Im on a Ubuntu 14.4 and the ROS Development Studion is on Ubuntu 16.4 with ROS Kinetic and Gazebo 7 I dont know if that information is relevant.

af-silva commented 5 years ago

It seems it's missing a header file from the g2o library. So, try to put this in the project folder and compile again. Are you using catkin?? If so try to compile the catkin branch of the repo.

The oficial repo for the g2o is here. I would recomend you to use Indigo instead of Kinetic maybe, but it should also work in kinetic. If everything fails, could you please try to use the LSD-SLAM port from my project, it has small changes in the code but for now it's is the only one I have sure to have worked in the ubuntu 14.04 distro under ROS Indigo (the oficial LSD-SLAM was having some troubles with catkin at the time, but the branch catking should also work). During the weekend if I have some time I can teste this, but if you could try the different approaches that I have mention above.

Good luck! ;)