【ROS学习-3】创建一个ROS Package
1.创建一个catkin
Package
执行如下命令创建一个catkin包:
cd
~/ros/catkin_ws/src/
catkin_create_pkg
beginner_tutorials std_msgs rospy roscpp
执行完会有如下提示:
Created
file beginner_tutorials/package.xml
Created
file beginner_tutorials/CMakeLists.txt
Created
folder beginner_tutorials/include/beginner_tutorials
Created
folder beginner_tutorials/src
Successfully
created files in
/home/guochongxin/ros/catkin_ws/src/beginner_tutorials. Please adjust
the values in package.xml.
上面的命令是使用catkin_create_pkg命令来创建一个名为beginner_tutorials的包,其依赖于std_msgs、rospy和roscpp。
2.编译catkin工作空间和导入setup文件
cd
~/ros/catkin_ws/
catkin_make
.
~/ros/catkin_ws/devel/setup.bash
3.包依赖关系
a.First-order依赖(直接依赖)
rospack
depends1 beginner_tutorials
执行后有如下返回值:
roscpp
rospy
std_msgs
跟创建包时设置的依赖包一致,这些包在package.xml中定义:
roscd
beginner_tutorials
cat
package.xml
执行后有如下一段:
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
b.Indirect依赖(间接依赖)
rospack
depends1 rospy
执行后有如下返回值:
genpy
roscpp
rosgraph
rosgraph_msgs
roslib
std_msgs
执行如下命令可以递归侦测所有的依赖:
rospack
depends beginner_tutorials
会返回如下值:
cpp_common
rostime
roscpp_traits
roscpp_serialization
catkin
genmsg
genpy
message_runtime
gencpp
geneus
gennodejs
genlisp
message_generation
rosbuild
rosconsole
std_msgs
rosgraph_msgs
xmlrpcpp
roscpp
rosgraph
rospack
roslib
rospy
4.自定义包配置信息
通过package.xml文件,有描述包信息的TAG:
<description>The
beginner_tutorials package</description>
包名:
<name>beginner_tutorials</name>
版本号:
<version>0.0.0</version>
包维护人员信息:
<maintainer
email="guochongxin@todo.todo">guochongxin</maintainer>
License信息:
<license>TODO</license>
编译时的依赖信息:
<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>
5.参考网址
评论
发表评论