Package creation and building

From Lofaro Lab Wiki
Jump to: navigation, search

When you start your new robotics project you will need to create nodes to run your sensors and actuators. You might need to make it in a large number. You will need to create and build ros packages first where you can put you node files and other libraries/tools.

Before creating a ros package you need to have a ros workspace. In our case a catkin workspace has been made. We can use the workspace to reside our packages. When you make a package it will give you a catkin complaint xml file and a cmake.txt file where the package information will be written. Let’s assume you have made a package named robo_package. If you command for file listing of the package instantly after creating it will show two files.

 CMakeLists.txt
 package.xml

To create a package, go to you catkin workspace, source folder by commanding

 $ cd ~/catkin_ws/src


 $ catkin_create_pkg robo_package std_msgs rospy roscpp


The above command will make a package named beginner-tutorial which have dependencies over std_msg, rospy and roscpp.

We can check the direct and indirect dependencies of the package by commanding

 $ rospack depends1 robo_package

And

 $ rospack depends1 rospy


If all dependencies are installed you can build your package

  1. In a catkin workspace
$ catkin_make 
$ catkin_make install --source my_src  # (optionally)