• +4917626969472
  • info@ur-techpartner.de

Important ROS Commands (08/09) – Catkin Commands

Important ROS Commands Robot Operating System(ROS1/ROS2)

Important ROS Commands –  Catkin Commands

The term “catkin” refers to the build system of the ROS. The ROS catkin commands are generally used when creating or building the ROS packages. Here we discuss most important and frequently used catkin commands

“catkin_create_pkg” Command

The “catkin_create_pkg” command is used to create an empty package. It is very important and useful command.

The structure of the command is as follows

catkin_create_pkg [Pckage_Name] [Dependency_Pckage1] [Dependency_Package2] […]

The command also creates “CMakeLists.txt” & “package.xml” files and “src” folder within the package.

Run the command

catkin_create_pkg my_first_test_package rospy std_msgs

Here a ROS package named “my_first_test_package” will be created. The package has dependencies on “rospy” and “std_msgs”.

We can go the the created package and run “ls” command to see if the files “CMakeLists.txt” & “package.xml” files and “src” folder are also created. Yes, thery are. We can modify the files “CMakeLists.txt” & “package.xml” according to our requirements. We may create python or other scripts in “src” folder.

“catkin_make” Command

Another very important ROS catkin command is “catkin_make” command. This command is used to build ROS packages. It is necessary that we should be in “catkin_ws” directory to build the packages. In order to build all packages in “carkin_ws” workspace run the following commands

First go to “catkin_ws”

cd catkin_ws

Now run following command

catkin_make

This will build all packages in current workspace. After building the packages you should also run “source” command to execute “setup.bash” file in “devel” folder. It is like to refresh the system so that latest changes must be available.

Run the command

source devel/setup.bash

Make a practice to run “source devel/setup.bash” every time, you make any changes and/or run “catkin_make” command.

“catkin_make –- only-pkg-with-deps” Command

Sometimes, there is a large number of packages available in your workspace and you don’t want to compile all packages. At that time you can use “catkin_make –-only-pkg-with-deps” command to build only one package with dependencies.

Run the command in terminal

catkin_make --only-pkg-with-deps my_first_test_package

Oh! there is an error, as shown in figure below

It is because we created “my_first_test_package” package in home directory.

We will have to create the package in “src” directory of “catkin_ws” folder. Because then the build command will successfully compile the package.

We go the the “catkin_ws/src” folder and create an other package

Run the command

cd ~/catkin_ws/src

Then run

catkin_create_pkg my_2nd_test_package rospy std_msgs

Now come out of “src” folder and stay in “catkin_ws” directory

For this run

cd ..

Now as you are already in “catkin_ws” directory, run the command

catkin_make --only-pkg-with-deps my_2nd_test_package

Now, you can see the package is compiled successfully.

Don’t forget to run the “source” command to execute “setup.bash” file in “devel” folder.

Run in terminal

source devel/setup.bash

We can see in figure below the compilation of the folder “my_2nd_test_package”. We have cut the figure shown below as there was more details.

There are many other “catkin” commands, which are not very frequently used such as catkin_eclipse, catkin_prepare_release, catkin_generate_changelog, catkin_init_workspace, and catkin_find.

You can run these commands with option “-h” to see what they do, and can practice them if needed. Further, we just go through one of these commands.

“catkin_find” Command

The command “catkin_find” shows all the working folders that we are using.

To view the working folders

Run the command

catkin_find

Additionally, if we give the package name after the “catkin_find”, it will show the working folders relevant to the specified package.

Run the command

catkin_find turtlesim

You can see the output of both commands in figure below

No comments