As you know that Package is the main building block for any Project you do in ROS.

In last Post, we created a workspace named “catkin_ws”.

Let’s understand the structure of package.

kkas

Just have a look. we are going to understand about it in a detail later.

To make the package, run the following command.

$ cd ~/catkin_ws/src

[command to change the working directory to “src”]

$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp

[command to create package of name “beginner_tutorials” with the dependencies “std_msgs”, “rospy” & “roscpp”. Adding the dependencies at this moment is optional.The name of the package is same as in roswiki for the readers convenience]

Now you will see the folder created in your “catkin_ws/src” folder named “beginner_tutorials”.

Now go to the “root” folder of the workspace and “build” the package.

In new terminal(Ctrl + Alt +T),run the following command

$ cd ~/catkin_ws

$ catkin_make

Your package package will look like this.

bt

lets learn about the components of Packages.

Package.xml

This file defines properties about the package such as the package name, version numbers, authors, maintainers, and dependencies on other packages.

Open “Package.xml”, and modify the file as per your wish.

  beginner_tutorials
  0.1.0
  The beginner_tutorials package
  Your Name
  BSD
  http://wiki.ros.org/beginner_tutorials
  Jane Doe
  catkin
  roscpp
  rospy
  std_msgs
  roscpp
  rospy
  std_msgs

CMakeLists.txt

This file is most important file in the package. This package guides ROS at the time of building the package. CMakeLists.txt contains the data about

  • Packages required to build this package
  • Msg/Service/Action generator
  • libraries/ executables to build

As we need , we will learn more about CMakeLists.txt

src: directory contains C/C++ codes

scripts: directory contains python codes

In new terminal(Ctrl + Alt +T),run the following command

$ cd ~/catkin_ws

$ catkin_make

Congratulations! Now you have the fundamental knowledge of the package and also you have your own package to place your codes in.