天天看点

【ROS学习】catkin_make 编译的小问题总结

写在前面

本博客旨在记录一些自己在编译 ROS 包的时候遇到的问题与解决方法

一、package.xml 下编译依赖<build_depend> 标签不全

执行 catkin_make 指令,出现如下报错:

Traceback (most recent call last):
  File "/opt/ros/kinetic/share/genjava/cmake/../../../lib/genjava/genjava_gradle_project.py", line 14, in <module>
    genjava.main(sys.argv)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genjava/genjava_main.py", line 82, in main
    gradle_project.create(args.package, args.output_dir)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genjava/gradle_project.py", line 152, in create
    raise IOError("could not find %s among message packages. Does the package have a <build_depend> on message_generation in its package.xml?" % msg_pkg_name)
IOError: could not find lidar_localization among message packages. Does the package have a <build_depend> on message_generation in its package.xml?
lidar_localization/CMakeFiles/lidar_localization_generate_messages_java.dir/build.make:62: recipe for target 'lidar_localization/java/lidar_localization/build.gradle' failed
make[2]: *** [lidar_localization/java/lidar_localization/build.gradle] Error 1
CMakeFiles/Makefile2:3378: recipe for target 'lidar_localization/CMakeFiles/lidar_localization_generate_messages_java.dir/all' failed
make[1]: *** [lidar_localization/CMakeFiles/lidar_localization_generate_messages_java.dir/all] Error 2
[ 15%] Built target libGeographiccc
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

           
【ROS学习】catkin_make 编译的小问题总结

注意报错信息里面的这句话:

could not find %s among message packages. Does the package have a <build_depend> on message_generation in its package.xml
           

翻译过来就是:

系统没有找到一些package,你确定把他们都放到了 package.xml 中的 <build_depend>  标签下了吗?
           

所以需要确保 自己的 package.xml 中的 <build_depend> 标签,有对应的 package (一般自定义的msg、srv、action,需要增加

<build_depend>message_generation</build_depend>

,这个容易忘记,自己就是忘记写这句话,才编译报错的…)

二、xxxxxxxx.patch文件找不到

执行 catkin_make 指令,出现如下报错:

  1. glog_catkin文件夹下的fix-unused-typedef-warning.patch文件找不到
/bin/sh: 1: cannot open /home/wong/test_ws/src/fix-unused-typedef-warning.patch: No such file
misc/glog_catkin/CMakeFiles/glog_src.dir/build.make:101: recipe for target 'misc/glog_catkin/glog_src-prefix/src/glog_src-stamp/glog_src-patch' failed
make[2]: *** [misc/glog_catkin/glog_src-prefix/src/glog_src-stamp/glog_src-patch] Error 2
CMakeFiles/Makefile2:531: recipe for target 'misc/glog_catkin/CMakeFiles/glog_src.dir/all' failed
make[1]: *** [misc/glog_catkin/CMakeFiles/glog_src.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
           

原因是glog_catkin文件夹下的fix-unused-typedef-warning.patch文件找不到,修改CMakeLists.txt文件:

解决方法:

(-) PATCH_COMMAND patch -p0 < ${CMAKE_SOURCE_DIR}/fix-unused-typedef-warning.patch
(+) PATCH_COMMAND patch -p0 < ${PROJECT_SOURCE_DIR}/fix-unused-typedef-warning.patch
           
  1. yaml_cpp_catkin 文件夹下的 fextra_version.patch文件找不到
/bin/sh: 1: cannot open /home/wong/test_ws/src/extra_version.patch: No such file
misc/yaml_cpp_catkin/CMakeFiles/yaml_cpp_src.dir/build.make:99: recipe for target 'misc/yaml_cpp_catkin/yaml_cpp_src-prefix/src/yaml_cpp_src-stamp/yaml_cpp_src-patch' failed
make[2]: *** [misc/yaml_cpp_catkin/yaml_cpp_src-prefix/src/yaml_cpp_src-stamp/yaml_cpp_src-patch] Error 2
CMakeFiles/Makefile2:6885: recipe for target 'misc/yaml_cpp_catkin/CMakeFiles/yaml_cpp_src.dir/all' failed
make[1]: *** [misc/yaml_cpp_catkin/CMakeFiles/yaml_cpp_src.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

           

原因是 yaml_cpp_catkin 文件夹下的 fextra_version.patch文件找不到,修改CMakeLists.txt文件:

解决方法:

(-) PATCH_COMMAND patch -p0 < ${CMAKE_SOURCE_DIR}/fix-unused-typedef-warning.patch
(+) PATCH_COMMAND patch -p0 < ${PROJECT_SOURCE_DIR}/fix-unused-typedef-warning.patch
           

参考链接:https://github.com/MuMuJun97/learning_note/blob/master/markdown%20files/%E6%9C%AA%E5%88%86%E7%B1%BB/ETH%20github%20—%EF%BC%881%EF%BC%89kitti%E6%95%B0%E6%8D%AE%E9%9B%86%E7%82%B9%E4%BA%91ros%E8%BD%AC%E6%8D%A2%E6%A0%BC%E5%BC%8F.md

三、*** No rule to make target …

执行 catkin_make 指令,出现如下报错:

make[2]: *** No rule to make target '/home/wong/test_ws/src/sim/rotors_simulator/rotors_gazebo_plugins/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by 'sim/rotors_simulator/rotors_gazebo_plugins/MagneticField.pb.cc'.  Stop.
CMakeFiles/Makefile2:10218: recipe for target 'sim/rotors_simulator/rotors_gazebo_plugins/CMakeFiles/mav_msgs.dir/all' failed
make[1]: *** [sim/rotors_simulator/rotors_gazebo_plugins/CMakeFiles/mav_msgs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
           

解决方法:

删除build文件夹里面的 rotors_gazebo_plugins ,然后重新 catkin_make 编译

参考链接:

[1] ROS无人机仿真rotor_simulations配置篇 https://www.it610.com/article/1280133876655603712.htm

[2] makefile报错 : make: No rule to make target https://blog.csdn.net/qq_27474467/article/details/80506882

四、Eigen库 /usr/include/eigen3/Eigen/src/StlSupport/StdVector.h 报错

执行 catkin_make 指令,出现如下报错:

/usr/include/eigen3/Eigen/src/StlSupport/StdVector.h:72:9: error: partial specialization of ‘class std::vector<Type, Eigen::aligned_allocator<Type> >’ after instantiation of ‘class std::vector<std::queue<Eigen::Matrix<long int, 3, 1>, std::deque<Eigen::Matrix<long int, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<long int, 3, 1> > > >, Eigen::aligned_allocator<std::queue<Eigen::Matrix<long int, 3, 1>, std::deque<Eigen::Matrix<long int, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<long int, 3, 1> > > > > >’ [-fpermissive]
   class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >
           

解决方法:

在出现错误相关联的文件中添加

#include <Eigen/StdVector>

,问题就会消失。

我自己遇到的情况是:

终端打印报错的文件都是在 map_manager_voxblox_impl.h 文件里,所以我在这个文件里添加

#include <Eigen/StdVector>

就成功编译了。

/home/wong/test_ws/src/exploration/mbplanner_ros/planner_common/include/planner_common/map_manager_voxblox_impl.h:97:10: error: ‘Index’ is not a member of ‘Eigen’
     for (Eigen::Index i = 0; i < matrix.size(); ++i) {
          ^
/home/wong/test_ws/src/exploration/mbplanner_ros/planner_common/include/planner_common/map_manager_voxblox_impl.h:97:30: error: ‘i’ was not declared in this scope
     for (Eigen::Index i = 0; i < matrix.size(); ++i) {

           

参考链接:

[1] ubuntu14.04安装maplab及问题详解 https://blog.csdn.net/snnily/article/details/79038726

[2] DSO_PCL踩坑+CMake+Boost+ROS+PCL+Eigen3 – https://www.jianshu.com/p/da9a859a9a8d

五、error: ‘Index’ is not a member of ‘Eigen’

执行 catkin_make 指令,出现如下报错:

/home/wong/test_ws/src/exploration/mbplanner_ros/planner_common/include/planner_common/map_manager_voxblox_impl.h:99:10: error: ‘Index’ is not a member of ‘Eigen’
     for (Eigen::Index i = 0; i < matrix.size(); ++i) {
           

报错显示:Index 不是 Eigen 的成员。

(这个自己没有查到,可能是Eigen版本的问题,自己看到 参考链接里面有涉及到

Eigen::Index

Eigen::VectorXd::Index

,所以就直接改成了

Eigen::VectorXd::Index

考虑到自己程序里这部分只是一个 普通的数值类型的 i,所以把程序中的

Eigen::Index

直接换成

Eigen::VectorXd::Index

解决方法:

把程序中的

Eigen::Index

换成

Eigen::VectorXd::Index

,然后重新 catkin_make 编译

参考链接:

[1] Use Eigen::Index instead of Eigen::VectorXd::Index :https://github.com/foobar27/anomaly/commit/7f62c152899eab808f57d8374379c4ea44f1c770