ROS学习(三)中,笔者不知道catkin到底是个什么东东,后来终于在官方网站上找到了答案,原来catkin是ROS的一个官方的编译构建系统,是原本的ROS的编译构建系统rosbuild的后继者。catkin的来源有点复杂,我们可以慢慢的讲一下其中的渊源。ROS来源于Willow Garage这个公司,他们希望借助开源的力量,使ROS发扬光大。而在英语中,willow的意思是柳树,catkin是柳絮的意思,为了纪念的作用吧,因而为这个软件命名为catkin。
这篇博客的主要内容是介绍如何使用catkin创建一个ROS包。一个catkin的包主要有以下几部分组成:(1)必须包括一个package.xml文件,(2)必须包括一个CMakeLists.txt文件,(3)在每一个文件夹下只能有一个包,且包不允许嵌套。一个最简单的包类似于如下的形式:
my_package/ CMakeLists.txt package.xml
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
首先进入到目录~/catkin_ws/src下,使用如下命令:
cd ~/catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
rospack depends1 beginner_tutorials
roscd beginner_tutorials cat package.xml
<package> ... <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend> ... </package>
rospack depends1 rospy
genpy rosgraph rosgraph_msgs roslib std_msgs
rospack depends beginner_tutorials
cpp_common rostime roscpp_traits roscpp_serialization genmsg genpy message_runtime rosconsole std_msgs rosgraph_msgs xmlrpcpp roscpp rosgraph catkin rospack roslib rospy
<description>The beginner_tutorials package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag --> <!-- Example: --> <!-- <maintainer email="[email protected]">Jane Doe</maintainer> --> <maintainer email="[email protected]">user</maintainer>
<!-- One license tag required, multiple allowed, one license per tag --> <!-- Commonly used license strings: --> <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> <license>TODO</license>
<!-- The *_depend tags are used to specify dependencies --> <!-- Dependencies can be catkin packages or system dependencies --> <!-- Examples: --> <!-- Use build_depend for packages you need at compile time: --> <!-- <build_depend>genmsg</build_depend> --> <!-- Use buildtool_depend for build tool packages: --> <!-- <buildtool_depend>catkin</buildtool_depend> --> <!-- Use run_depend for packages you need at runtime: --> <!-- <run_depend>python-yaml</run_depend> --> <!-- Use test_depend for packages you need only for testing: --> <!-- <test_depend>gtest</test_depend> --> <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend> <run_depend>rospy</run_depend> <run_depend>std_msgs</run_depend>