To create a package for Ros--3

Source: Internet
Author: User

Create Ros Package (original post, reprint please indicate source-Zhou Xuewei)

1. What is a Catkin package made up of?

A package that you want to call a Catkin package must meet the following requirements:

      • The package must contain Catkin compliant package.xml file
      • This package.xml file provides meta-information about the package.
      • The package must contain a catkin version of the CMakeLists.txt file, and Catkin metapackages must contain a reference to the CMakeList.txt file.

      • There can be only one package per directory.
      • This means that there cannot be nested or multiple packages in the same directory.

The simplest package might look like this:

my_package/  CMakeLists.txt  package.xml

2. Packages in the Catkin workspace

  One recommended way to develop a Catkin package is to use the Catkin workspace, but you can also develop (standalone) Catkin packages separately. A simple work space might look like this:

 workspace_folder/-- workspace src /-- SOURCE SPACE CMakeLists.txt -- " tople    Vel   "  CMake file, provided by Catkin Package_1 / CMakeLists.txt --CMakeLists.txt file for   Package_1 package.xml --Package manifest for   Package_1 ... package_n / Cmakeli Sts.txt --CMakeLists.txt file for  --Package manifest for  package_n 

Before continuing this tutorial, create a blank Catkin workspace by following the Create Catkin workspace tutorial.

 3. Create a Catkin Package

This section of the tutorial shows you how to use the catkin_create_pkg command to create a new Catkin package and what you can do after you create it.

First switch to the SRC directory in the Catkin workspace created earlier by creating the Catkin Workspace Tutorial:

 This inch  ~/CATKIN_WS/SRC

Now use the catkin_create_pkg command to create a new package called ' Beginner_tutorials ', which relies on std_msgs, Roscpp, and Rospy:

Catkin_create_pkg beginner_tutorials std_msgs Rospy roscpp

This will create a folder named Beginner_tutorials , which contains a package.xml file and a CMakeLists.txt file, all of which are automatically included in the two files you are performing the information provided when the CATKIN_CREATE_PKG command is available.

The catkin_create_pkg command will ask you to enter package_name, and you can add some additional packages that you need to rely on later if you need to:

 is  Do Try  This  <package_name> [Depend1] [Depend2] [Depend3]

The catkin_create_pkg command also has more advanced features, which are described in catkin/commands/catkin_create_pkg.

 4. Package dependencies

  4.1. First-level dependency

Before using the CATKIN_CREATE_PKG command to provide several packages as a dependency package, we can now use the rospack Command tool to view a one-tier dependency package.

Jan 9, there is a bug reported and already fixed in rospack in groovy, which takes sometime until the change gets re flected on your computer. If you see a similar issue like this and the next command, you can skip to the next command.

[Email protected]:

As you can see,rospack lists the dependent packages that are used as parameters when you run the catkin_create_pkg command, which are then saved in the package.xml file.

[email protected]: roscd beginner_tutorials[email protected]: cat Package.xml

 4.2. Indirect Reliance

(Jan 9, 2013) There is a bug reported and already fixed in rospack in groovy, which takes sometime until the change gets reflected on yo ur computer. If you see a similar issue like this and the next command, you can skip to the next command.
[email protected]: rospack depends1 Rospy

A package can also have several indirect dependencies, and fortunately, using rospack , you can recursively detect all dependent packages.

[email protected]: Rospack depends beginner_tutorials

Cpp_commonRostimeRoscpp_traitsRoscpp_serializationGenmsgGenpyMessage_runtimeRosconsoleStd_msgsrosgraph_msgsxmlrpcpproscpprosgraphcatkinrospackroslibrospy   

  5. Customize your Package

This section of the tutorial will dissect each file generated by the catkin_create_pkg command and describe in detail the parts of these files and how to customize them.

  5.1. Custom Package.xml

The auto-generated package.xml file should be in your new package. Now let's take a look at the newly generated package.xml file and every tag element that needs your attention.

First open the package.xml with the VIM editor

  

[email protected]: vim package.xml

5.1.1. Description Label::

    

Modify the description information to anything you like, but the first sentence should be short, as it covers the scope of the package. If it's hard to describe in a word, it needs to be changed.

5.1.2. Maintainer Label::

    

This is an important label that is required in package.xml because it allows others to contact the person who is involved in the package. You need to fill in at least one maintainer name, but you can add multiple if necessary. In addition to filling in the name of the maintainer in the label, you should also fill in the email address of the label's email attribute:

5.1.3. License Tags::

    

You should choose a license agreement and fill it out here. Some common open source licensing agreements include BSD, MIT, Boost software License, GPLv2, GPLv3, LGPLv2.1, and LGPLv3. You can read about several of these license agreements in open Source initiative. For this tutorial we will use the BSD protocol because the remainder of the ROS core component already uses the protocol:

5.1.4. Dependency Tags::

    

In addition to the Buildtool_dependprovided by default in Catkin, all of the dependent packages we have listed have been added to the build_depend tag. In this case, because we need to use all the specified dependencies at compile and run time, we also need to add each dependent package separately to the run_depend tag: The final file content is stripped of comments and dependencies::

    

   1<?xml version="1.0"?>2<package>3<name>beginner_tutorials</name>4<version>0.1.0</version>5<description>the beginner_tutorials package</description>6    7<maintainer email="[email protected]">your name</maintainer>8<license>BSD</license>9<url type="website">http://wiki.ros.org/beginner_tutorials</url>  Ten<author email="[email protected]">jane doe</author> One    A<buildtool_depend>catkin</buildtool_depend> -    -<build_depend>roscpp</build_depend> the<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> +    A</package

5.2. Custom CMakeLists.txt

Here, the package.xml file containing the package meta-information has been trimmed as needed, and now you can continue with the tutorial below. The CMakeLists.txt file generated by the CATKIN_CREATE_PKG command will be described in subsequent tutorials on compiling the ROS program code.

Now that you've created a new Ros package, we'll start compiling the package

To create a package for Ros--3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.