-
Notifications
You must be signed in to change notification settings - Fork 1
Creating and Building ROS Package
In this part of the tutorial, you will learn how to create a ROS package.
Note: Make sure you have already installed and configured your ROS environment.
A ROS package is (under the hood) a catkin package.
For a package to be considered a catkin package it must meet a few requirements:
-
The package must contain a catkin complaint
package.xml
file, also called the package manifest. -
The package must contain a
CMakeLists.txt
file which uses catkin. -
The package must be contained within its own separate folder, i.e., there can be no nesting of packages, or multiple packages sharing the same directory.
Note: An empty package would have the following structure
my_package/ CMakeLists.txt package.xml
To create a new catkin package, first, navigate to the source folder of the catkin workspace you wish to use
cd ~/<workspace_name>/src
Now to create the package, run
catkin_create_pkg <package_name> [dependency1] [dependency2]
Your package may or may not have some dependencies - these arguments are optional.
You can build the catkin package by building the catkin workspace in which it is contained.
Using rospack
The rospack
tool allows us to get information about packages.
When using catkin_create_pkg
earlier, a few package dependencies were provided. These so-called direct dependencies can now be reviewed with the depends1
command.
rospack depends1 <package_name>
These dependencies should be specified within the package manifest.
Note: If the dependencies are specified when using the
catkin_create_pkg
command, they are automatically added to the package manifest.
Packages can have four types of dependencies:
-
Build Tool Dependencies specify build system tools that this package needs to build itself. Typically the only build tool needed is catkin.
-
Build Dependencies specify which packages are needed to build this package. This is the case when any file from these packages is required at build time.
-
Run Dependencies specify which packages are needed to run code in this package or build libraries against this package.
-
Test Dependencies specify only additional dependencies for unit tests. They should never duplicate any dependencies already mentioned as build or run dependencies.
Sometimes the direct dependencies may themselves have dependencies. We refer to these as indirect dependencies.
We can view all (direct and indirect) dependencies of a package using
rospack depends <package_name>
Now that you have created and built a ROS package, you should make sure you understand ROS architecture.
General ROS and Technical Help
- Creating a rospy package
- Model the Robot
- Odometry - General Information
- Odometry - Configuring with ROS
Creating and Using Our Packages