Creating a ROS Package by Hand

From Lofaro Lab Wiki
Jump to: navigation, search

Close all opened terminals.

1) In a terminal window, navigate to your catkin workspace:

cd ~/catkin_ws

2) Source the setup file:

source ./deevel/setup.bash

3) Create a folder called foobar in the src folder, and navigate into it:

mkdir -p src/foobar
cd src/foobar

4) Create the file packages.xml:

gedit package.xml

In the editor paste the following:

<package>
  <name>foobar</name>
  <version>1.2.4</version>
  <description>
  This package provides foo capability.
  </description>
  <maintainer email="foobar@foo.bar.willowgarage.com">PR-foobar</maintainer>
  <license>BSD</license>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>

  <run_depend>roscpp</run_depend>
  <run_depend>std_msgs</run_depend>
</package>

Save the file and close the editor.

5) To check that the package.xml was sucessful, have ROS find it:

rospack find foobar

Something like "/home/gmustudent/catkin_ws/src/foobar" will print

6) Create the file CMakeLists.txt:

gedit CMakeLists.txt

In the editor paste the following:

cmake_minimum_required(VERSION 2.8.3)
project(foobar)
find_package(catkin REQUIRED roscpp std_msgs)
catkin_package()

Save the file and close the editor.

7) To check that both files are in the foobar folder:

ls

This should display "CMakeLists.txt Package.xml"

These files don't do anything but they are the minimum needed for creating a ROS Package.