标签:common rip ebs pack gtest yaml depends format enc
本文讲如何用catkin创建一个ROS的package
1. catkin package的组成:一定要包含CMakeLists.txt及package.xml文件
my_package/ CMakeLists.txt package.xml
此外,每个package必须要有他自己的文件夹。
2. 推荐使用catkin workspace来处理catkin package
workspace_folder/ -- WORKSPACE src/ -- SOURCE SPACE CMakeLists.txt -- ‘Toplevel‘ CMake file, provided by catkin package_1/ CMakeLists.txt -- CMakeLists.txt file for package_1 package.xml -- Package manifest for package_1 ... package_n/ CMakeLists.txt -- CMakeLists.txt file for package_n package.xml -- Package manifest for package_n
3. 创建catkin package
使用catkin_create_pkg脚本来创建新的catkin package:
(1)切换source space目录至之前创建的catkin workspace
$ cd ~/catkin_ws/src
(2)用catkin_create_pkg创建一个catkin package,名字是beginner_tutorials,且依赖于已有的功能包std_msgs,roscpp,rospy,后者称为dependency
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
4. build 这个catkin workspace, source 这个setup文件
build方法:
$ cd ~/catkin_ws $ catkin_make
source方法:
$ . ~/catkin_ws/devel/setup.bash
5. package dependencies
(1)用rospack查看1阶dependencies:
$ rospack depends1 beginner_tutorials
package.xml中储存了package的dependencies信息
$ roscd beginner_tutorials $ cat package.xml
(2)用rospack查看间接(高阶)的dependencies:
$ rospack depends beginner_tutorials
6. customize(自定义、定制) package
6.1 自定义package.xml
(1) 描述标签(description tag):尽可能短
5 <description>The beginner_tutorials package</description>
(2)Maintainer 标签:必须有,而且非常重要,至少要有一条。作用是让别人知道有关这个package该联系谁。
Toggle line numbers 7 <!-- One maintainer tag required, multiple allowed, one person per tag --> 8 <!-- Example: --> 9 <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> --> 10 <maintainer email="user@todo.todo">user</maintainer>
(3)许可证标签(license tag):有很多开源许可证,我们这里使用BSD,因为许多ROS核心部件都是用的它。
12 <!-- One license tag required, multiple allowed, one license per tag --> 13 <!-- Commonly used license strings: --> 14 <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> 15 <license>TODO</license>
(4)dependencies标签: dependencies标签可分为build_depend, buildtool_depend, exec_depend, test_depend。因为我们使用了std_msgs, roscpp, and rospy,所以该标签应为:
27 <!-- The *_depend tags are used to specify dependencies --> 28 <!-- Dependencies can be catkin packages or system dependencies --> 29 <!-- Examples: --> 30 <!-- Use build_depend for packages you need at compile time: --> 31 <!-- <build_depend>genmsg</build_depend> --> 32 <!-- Use buildtool_depend for build tool packages: --> 33 <!-- <buildtool_depend>catkin</buildtool_depend> --> 34 <!-- Use exec_depend for packages you need at runtime: --> 35 <!-- <exec_depend>python-yaml</exec_depend> --> 36 <!-- Use test_depend for packages you need only for testing: --> 37 <!-- <test_depend>gtest</test_depend> --> 38 <buildtool_depend>catkin</buildtool_depend> 39 <build_depend>roscpp</build_depend> 40 <build_depend>rospy</build_depend> 41 <build_depend>std_msgs</build_depend>
我们希望在build和run的时候使用所有特定的dependencies,因此我们还要增加exec_depend标签,最后如下:
12 <buildtool_depend>catkin</buildtool_depend> 13 14 <build_depend>roscpp</build_depend> 15 <build_depend>rospy</build_depend> 16 <build_depend>std_msgs</build_depend> 17 18 <exec_depend>roscpp</exec_depend> 19 <exec_depend>rospy</exec_depend> 20 <exec_depend>std_msgs</exec_depend>
(5) 最终的package.xml:下面是不含有评论和未使用tag的package.xml文件,非常concise(简明)
<?xml version="1.0"?> <package format="2"> <name>beginner_tutorials</name> <version>0.1.0</version> <description>The beginner_tutorials package</description> <maintainer email="you@yourdomain.tld">Your Name</maintainer> <license>BSD</license> <url type="website">http://wiki.ros.org/beginner_tutorials</url> <author email="you@yourdomain.tld">Jane Doe</author> <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend> <exec_depend>roscpp</exec_depend> <exec_depend>rospy</exec_depend> <exec_depend>std_msgs</exec_depend> </package>
6.2 自定义CMakeLists.txt
标签:common rip ebs pack gtest yaml depends format enc
原文地址:http://www.cnblogs.com/jjxforever/p/8006687.html