创建package和查看package的依赖关系
Creating a ROS Package目录
Using roscreateBefore we create a package,let's see how the roscreate-pkg command-line tool works. This creates a new ROS package. All ROS packages consist of the many similar files : manifests, CMakeLists.txt,mainpage.dox,and Makefiles. roscreate-pkg eliminates many tedious tasks of creating a new package by hand,and eliminates common errors caused by hand-typing build files and manifests. To create a new package in the current directory:
$ roscreate-pkg [package_name]
You can also specify dependencies of that package:
$ roscreate-pkg [package_name] [depend1] [depend2] [depend3]
Creating a New ROS PackageNow we're going to go into your home or project directory and create our beginner_tutorials package. We are going to make it depend on std_msgs,roscpp,and rospy,which are common ROS packages. Now go into the ~/fuerte_workspace/sandbox directory: $ cd ~/fuerte_workspace/sandbox
Alternatively,if you use Fuerte or later release,you can simply do: $ roscd
Then create your package: $ roscreate-pkg beginner_tutorials std_msgs rospy roscpp
You will see something similar to:
You're going to want to spend some time looking at beginner_tutorials/manifest.xml. manifests play an important role in ROS as they define how Packages are built,run,and documented. Now lets make sure that ROS can find your new package. It is often useful to call rospack profile after making changes to your path so that new directories will be found:
$ rospack profile
$ rospack find beginner_tutorials
If this fails,it means ROS can't find your new package,which may be an issue with your ROS_PACKAGE_PATH. Please consult the installation instructions for setup from SVN or from binaries,depending how you installed ROS. If you've created or added a package that's outside of the existing package paths,you will need to amend your ROS_PACKAGE_PATH environment variable to include that new location. Try re-sourcing your setup.sh in your fuerte_workspace. Try moving to the directory for the package. $ roscd beginner_tutorials
$ pwd
First-order package dependenciesWhen using roscreate-pkg earlier,a few package dependencies were provided. These first-order dependencies can now be reviewed with the rospack tool.
$ rospack depends1 beginner_tutorials
As you can see,rospack lists the same dependencies that were used as arguments when running roscreate-pkg. These dependencies for a package are stored in the manifest file. Take a look at the manifest file.
$ roscd beginner_tutorials
$ cat manifest.xml
Indirect package dependenciesIn many cases,a dependency will also have its own dependencies. For instance,rospy has other dependencies. $ rospack depends1 rospy
A package can have quite a few indirect dependencies. Luckily rospack can recursively determine all nested dependencies. $ rospack depends beginner_tutorials
Note: in Fuerte,the list is much shorter: std_msgs
roslang
rospy
roscpp (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |