编译ROS程序遇到的问题

package.xml的修改

Cmakelist.txt和package.xml的编写参考A Gentle Introduction to ROS一书,需将package.xml中的

<build_depend>roscpp</build_depend>
<run_depend>roscpp</run_depend>

改为

<build_depend>roscpp</build_depend>
<build_export_depend>roscpp</build_export_depend>
<exec_depend>roscpp</exec_depend>

可参考官方文档(原因:Package format 1和Package format 2不同)

其它

执行catkin_make需在workspace下执行, 参考链接

若出现如下错误

CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/home/mkxiong/anaconda3/bin/python
  "/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/kinetic/share/catkin/cmake/../package.xml"
  "/home/mkxiong/Documents/mycode/ros/build/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake:63 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:151 (_catkin_package_xml)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:52 (find_package)

则执行

pip install catkin_pkg
上篇视觉SLAM两本必读书籍推荐
下篇Ubuntu16.04下安装NVIDIA驱动、CUDA、cuDNN、OpenCV、Caffe、ROS和小飞机bebop