What is Catkin?
This tool is developed for ROS, the robotics operating system, by the team building the ROS tools. It has a multitude of tools to build your robotics project. Using it will be necessary if you develop robots using ROS. You should be aware that there have been several generations of these tools over the last few years. This means you need to choose the newest! Catkin is installed with the full ROS noetic distribution; all you need to take care of is the configuration. You need to set the correct environment for running Catkin.
Setting up the directory/environment
Create a directory with sub-directory src/ inside it. MyRob/src. The examples are from the beginner tutorial.
catkin_make creates CMakelists.txt in the src directory. These point to the other files that make up a project.
Next, you want to create your packages.
Go in the src directory
$ catkin_createpkg beginner_tutorials std_msgs ropy roscpp
Note the mistake in the command. This creates everything as if you were not mistaken. You can find the result in the files with grep.
$ grep -r ropy.
./CMakeLists.txt:# CATKIN_DEPENDS ropy roscpp std_msgs
The next compile will fail. You now have two choices, edit the files or remove the entire directory. The script is usually fast so the easiest is to remove and re-run the create command. Once you have cleared those mistakes, you continue by building the package. Either way, when you have fixed it, go to the workspace root and run catkin_make again. As you move on with any project, you will always go back up to the workspace root to make the whole project. This only makes sure that everything exists correctly, there are some clever tricks so you don’t have to recompile the whole project every time.
If it succeeds this time, you have just created your first package. Remember to fix up your package.xml file. You should probably set your name correctly and the license. There are more settings, they are all easy to understand.
A small project
Now, do it again in a new directory and create your project. Or better yet: for practice, pick up a project from GitHub, see where it goes, and then start changing it to your liking. To do this, you can create a workspace for catkin with a src directory. In the source directory, you copy in the source code directories. From the example, above you need two steps, clone the directory and run catkin_make.
$ git clone https://github.com/crkaushik93/Go-Chase-It-RSEND-Project-2.git
$ cd ..
To make a less deep tree, you may move each sub-directory up one step but this is optional. The last command will search the src/ directory and find all code.
You do not usually install packages on the development system only. However, you run install to create an install environment and a development environment. The catkin_make command creates these for you. As you move on you should source one for development and the other for testing. A direct install will create your directories, including the scripts to initialize the environments.
You will not have the files installed on your system, only in the project directory. This is great because all you need to do is run the setup and start testing.
The first is for you to run testing and find out what mistakes you have embedded in your code.
So, is this only valid for ROS1? Yes, catkin is aimed only at the ROS1 libraries. One thing to note though is that most of the job is cmake. You will be able to translate many of the practices to other projects that uses CMake. You only need to do more work since Catkin has simplified many tasks for you. For ROS2, many things are similar but the solutions are more refined and have more features to control how much you compile each time. You can also program in both levels of ROS, there is a bridge between the two!
Catkin is a very strong and versatile set of tools that makes your work much simpler and lets you get through the grind of developing your robotics code. The practices, though are an excellent way to learn more about programming. So even if your robot project is only for your closest circle and bragging rights, you can benefit from knowledge for other projects.