本文主要是介绍创建一个ROS Package,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.创建一个catkinPackage
执行如下命令创建一个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 thevalues 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
catpackage.xml
执行后有如下一段:
catkin
roscpp
rospy
std_msgs
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:
The beginner_tutorials package
包名:
beginner_tutorials
版本号:
0.0.0
包维护人员信息:
guochongxin@todo.todo">guochongxin
License信息:
TODO
编译时的依赖信息:
catkin
roscpp
rospy
std_msgs
运行时的依赖信息:
roscpp
rospy
std_msgs
参考网址:ROS/Tutorials/CreatingPackage - ROS Wiki
这篇关于创建一个ROS Package的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!