Size: 5036
Comment:
|
Size: 5054
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 136: | Line 136: |
$ rospack depends | $ rospack depends beginner_tutorials |
Note: This tutorial assumes that you have completed the previous tutorials: Navegando pelo sistema de arquivos do ROS. |
![]() |
Criando um Pacote ROS
Description: Este tutorial cobre a utilização de roscreate-pkg ou catkin para criar um novo pacote, e rospack para listar dependências de pacotes.Tutorial Level: BEGINNER
Next Tutorial: Gerando um pacote ROS
Contents
Quick Environment Variable Setup
For this tutorial, you will need to know two key environment variables:
ROS_ROOT: this is the directory where ROS is installed and contains many ROS-related packages
ROS_PACKAGE_PATH: this is a of directories that ROS looks to find more ROS packages.
Using roscreate
Before we create a package, let's see how the roscreate-pkg command-line tool works. This creates a new ROS package: manifest, CMakeLists.txt, mainpage.dox, and Makefile. It addresses the common problem of packages being created by hand using pre-existing packages, which leads to errors in build files and manifests.
To create a new package in the current directory:
$ roscreate-pkg pkgname
You can also specify dependencies of that package:
$ roscreate-pkg pkgname depend1 depend2 depend3
Creating a New ROS Package
Now we're going to go into the ros_tutorials directory and create our beginner_tutorials package. We going to make it depend on roscpp and rospy, which are common ROS packages, as well as rospy_tutorials, which has some programs we're going to use later.
$ roscd ros_tutorials $ roscreate-pkg beginner_tutorials std_msgs rospy roscpp rospy_tutorials roscpp_tutorials turtlesim
You will see:
Creating package directory ~/ros/ros_tutorials/beginner_tutorials Creating include directory ~/ros/ros_tutorials/beginner_tutorials/include/beginner_tutorials Creating cpp source directory ~/ros/ros_tutorials/beginner_tutorials/src Creating python source directory ~/ros/ros_tutorials/beginner_tutorials/src/beginner_tutorials Creating package file ~/ros/ros_tutorials/beginner_tutorials/Makefile Creating package file ~/ros/ros_tutorials/beginner_tutorials/manifest.xml Creating package file ~/ros/ros_tutorials/beginner_tutorials/CMakeLists.txt Creating package file ~/ros/ros_tutorials/beginner_tutorials/mainpage.dox Please edit beginner_tutorials/manifest.xml and mainpage.dox to finish creating your package
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:
$ rospack find beginner_tutorials
~/ros/ros_tutorials/beginner_tutorials
Try moving to the directory for the package.
$ roscd beginner_tutorials $ pwd
~/ros/ros_tutorials/beginner_tutorials
First-order package dependencies
Some depencancies where provided earlier to roscreate-pkg. These first-order dependencies can be provided by the rospack tool.
$ rospack depends1 beginner_tutorials
std_msgs rospy roscpp rospy_tutorials roscpp_tutorials turtlesim
These are the same dependencies that were specified when using roscreate-pkg. This dependencies for a package are stored in the manifest file. Take a look at the manifest file.
$ roscd beginner_tutorials $ cat manifest.xml
<package> ... <depend package="std_msgs"/> <depend package="rospy"/> <depend package="roscpp"/> <depend package="rospy_tutorials"/> <depend package="roscpp_tutorials"/> <depend package="turtlesim"/> </package>
Indirect package dependencies
In many cases a dependency will also have its own dependencies. For instance rospy has some dependencies.
$ rospack depends1 rospy
roslib roslang
A package can have quite a few indirect dependencies. Luckily rospack can recursively determine all nested dependencies.
$ rospack depends beginner_tutorials
enmsg_cpp roslib std_msgs roslang rospy xmlrpc++ rosconsole roscpp pycrypto paramiko rosout roslaunch rostest std_srvs roscpp_tutorials rospy_tutoria
Now that you've made a new ROS package, let's create a ROS msg and srv.