我的ros系统是用的小鱼的一键安装链接,参考:
ubuntu-18.04一键安装ros_ros18.04yijian-CSDN博客
我编译./build_ros.sh的时候遇到的问题,查遍csdn都没找到解决方法
问题一:
CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:129 (message):
Failed to invoke rospack to get compile flags for package 'ORB_SLAM2'.
Look above for errors from rospack itself. Aborting. Please fix the
broken dependency!
Call Stack (most recent call first):
/opt/ros/melodic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
CMakeLists.txt:4 (rosbuild_init)
-- Configuring incomplete, errors occurred!
See also "/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。
CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:129 (message):
Failed to invoke rospack to get compile flags for package 'ORB_SLAM2'.
Look above for errors from rospack itself. Aborting. Please fix the
broken dependency!
Call Stack (most recent call first):
/opt/ros/melodic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
CMakeLists.txt:4 (rosbuild_init)
-- Configuring incomplete, errors occurred!
See also "/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。
解决方法:
sudo rosdep init
rosdep update
即可,运行rosdep update的时候可能遇到rosdep update错误失败一直timeout的问题,如:The read operation timed out(包括ERROR: unable to process source,ERROR: error loading sources list
可参考解决方法:rosdep update错误失败一直timeout解决方法_rosdep update出错-CSDN博客(本人实测方法二有效)
问题二:
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc: In member function ‘void ORB_SLAM2::ViewerAR::Run()’:
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc:233:9: error: ‘usleep’ was not declared in this scope
233 | usleep(mT*1000);
| ^~~~~~
CMakeFiles/MonoAR.dir/build.make:190: recipe for target 'CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o' failed
make[2]: *** [CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o] Error 1
CMakeFiles/Makefile2:543: recipe for target 'CMakeFiles/MonoAR.dir/all' failed
make[1]: *** [CMakeFiles/MonoAR.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc: In member function ‘void ORB_SLAM2::ViewerAR::Run()’:
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc:233:9: error: ‘usleep’ was not declared in this scope
233 | usleep(mT*1000);
| ^~~~~~
CMakeFiles/MonoAR.dir/build.make:190: recipe for target 'CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o' failed
make[2]: *** [CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o] Error 1
CMakeFiles/Makefile2:543: recipe for target 'CMakeFiles/MonoAR.dir/all' failed
make[1]: *** [CMakeFiles/MonoAR.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
解决方法:
在orb_slam2文件夹中搜索:ViewerAR.cc,打开
引入头文件:
#include<unistd.h>
即可解决问题