在一个ROS功能包中,CMakeList.txt和package.xml是不可缺少的两个文件。
最近听师兄说,如果xml文件出错了,功能包会无法通过
我是比较怀疑这个说法的,毕竟官方原文是这样说的:
Your system package dependencies are declared in package.xml. If they are missing or incorrect, you may be able to build from source and run tests on your own machine, but your package will not work correctly when released to the ROS community.
于是带着疑问,我进行了一些实验:
(1)把包里的xml文件直接删掉:
删掉之后进行catkin_make,通过,但cpp文件并没有被编译,看上去ROS系统并没有把它当作一个功能包。这证明了xml文件是功能包被ROS系统识别的前提。
(2)在xml文件中把 <build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>std_msgs</run_depend>这几句删掉,并把devel和build文件夹删掉:
cpp文件被编译,整个catkin_make也能通过。
(3)在xml文件中把<buildtool_depend>catkin</buildtool_depend>删掉,并把devel和build文件夹删掉:
catkin_make报错:
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake:116 (message):
catkin_package() 'catkin' must be listed as a buildtool dependency in the
package.xml
(4)删除<version>0.0.0</version>:
报错:
Error(s) in package '/home/ch/forTest/src/minimal_nodes/package.xml':
The manifest must contain exactly one "version" tag
结论:删掉 <build_depend>和<run_depend>并没有影响catkin_make的通过,而删除其他tags就会导致功能包编译失败
所以,<build_depend>和<run_depend>到底起什么作用?