Creating a ROS Package
Creating a ROS Package
A workspace is created, then a ROS package within the workspace.
Creating a Workspace for Catkin
1) We create a src file in the catkin_ws folder, move into it, and create a workspace called catkin_init_workspace:
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src catkin_init_workspace
2) Then we build the workspace:
cd ~/catkin_ws/ catkin_make
3) And create the setup.*sh file:
source devel/setup.bash
Creating a ROS Package
4) Make sure you are in the src folder you had created earlier:
cd ~/catkin_ws/src
5) Now we create a new ROS package: catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
This will create a beginner_tutorials folder which contains a package.xml and a CMakeLists.txt 5a) The package.xml contains the names of the dependenices. These can be checked by looking at the folder or typing:
rospack depends1 beginner_tutorials
5b) To see all dependencies for the package and dependencies given in the xml:
rospack depends beginner_tutorials
The xml file has a description (line 5), maintainer tag (lines 7,9, and 10), license tag (line 8), and dependency list (lines 12-20). Below is given a concise example of our beginner_tutorial xml file:
1 <?xml version="1.0"?> 2 <package> 3 <name>beginner_tutorials</name> 4 <version>0.1.0</version> 5 <description>The beginner_tutorials package</description> 6 7 <maintainer email="you@yourdomain.tld">Your Name</maintainer> 8 <license>BSD</license> 9 <url type="website">http://wiki.ros.org/beginner_tutorials</url> 10 <author email="you@yourdomain.tld">Jane Doe</author> 11 12 <buildtool_depend>catkin</buildtool_depend> 13 14 <build_depend>roscpp</build_depend> 15 <build_depend>rospy</build_depend> 16 <build_depend>std_msgs</build_depend> 17 18 <run_depend>roscpp</run_depend> 19 <run_depend>rospy</run_depend> 20 <run_depend>std_msgs</run_depend> 21 22 </package>