Creating catkin package in ROS
- Shivangi
- Jan 3, 2017
- 2 min read
A brief intro:
The ROS packages are the basic unit of the ROS system. We can create the ROS
package, build it and release it to the public. Here we will be using catkin build systems to build our ROS packages. A build system is responsible for generating 'targets' (executable/libraries) from a raw source code that can be used by an end user. In older distributions, such as Electric and Fuerte, rosbuild was the build system. Because of the various flaws of rosbuild , catkin came into existence, which is basically based on CMake (Cross Platform Make). This has lot of advantages such as porting the package into other operating system, such as Windows. If an OS supports CMake and Python, catkin based packages can be easily ported into it.
Procedure:
Creating workspace:
The first requirement in creating ROS packages is to create a ROS catkin workspace. Here is the procedure to build a catkin workspace:
1.To setup your environment to use the /opt/ros/<distro>(where distro refers to various distributions like jade,kinetic) installation space, source the setup file for your shell using the following command:
sudo apt-get install ros-kinetic-catkin
source /opt/ros/<distro>/setup.bash
2.Build a workspace folder in the home directory and create a src folder inside the
-workspace folder:
mkdir -p ~/catkin_ws1/src
3.Then navigate to catkin workspace using command:
cd ~/catkin_ws1/
4.The catkin_make command will build the following workspace:
catkin_make
Because of the above command we wil find three new folders namely-build,devel,src. The build folder is the default location of the build space is where cmake and make are called to configure and build your packages. The devel folder is the default location of the devel space, which is where your executables and libraries go before you install your packages.
5.Inside the devel folder now there are several setup.sh files. We will source the setup.bash file to overlay this workspace on top of your ROS environment
source ~/catkin_ws1/devel/setup.bash
6.Now navigate out of this using this command in the terminal :
cd
7.Then add source command to .bashrc file using this command:
echo “source ~/catkin_ws1/devel/setup.bash”>>~/.bashrc
8.To make sure workspace is properly overlaid by the setup script make sure the ros package path environment variable includes the directory in you're in use the following command:
echo $ROS_PACKAGE_PATH
The output will be:
/home/shivangi/catkin_ws1/src: /opt/ros/kinetic
File system of workspace folder
workspace_folder/ -- WORKSPACE
src/ -- SOURCE SPACE
CMakeLists.txt -- 'Toplevel' CMake file, provided by
catkin
package_1/
CMakeLists.txt -- CMakeLists.txt file for package_1
package.xml -- Package manifest for package_1
...
package_n/
CMakeLists.txt -- CMakeLists.txt file for package_n
package.xml -- Package manifest for package_n
Creating ROS Package:
1.Navigate to source folder in workspace using command:
cd ~/catkin_ws1/src
2.Then create catkin package using the command:
catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
where [depend1] [depend2] [depend3]…. are the dependencies.
Eg:
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp actionlib actionlib_msgs
where std_msgs ,rospy ,roscpp ,actionlib ,actionlib_msgs are dependencies of the package.
FINALLY CATKIN PACKAGE IS CREATED!!!
Here is the video for the above tutorial-
留言