my_package/
CMakeLists.txt
package.xml
package.xml
provides meta information about the package.
CMakeLists.txt
contains build instructions for CMake, and must use catkin CMake variables.
Maintain a single development workspace, called 'catkin workspace', containing all catkin packages. Aliased as catkin_ws
by setup.bash
(see next section).
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
Sample package.xml:
<?xml version="1.0"?>
<package>
<name>beginner_tutorials</name>
<version>0.1.0</version>
<description>The beginner_tutorials package</description>
<maintainer email="[email protected]">Your Name</maintainer>
<license>BSD</license>
<url type="website">http://wiki.ros.org/beginner_tutorials</url>
<author email="[email protected]">Jane Doe</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
</package>
Must follow the following format:
cmake_minimum_required()
project()
# Only use for build (!run) time dependencies, message_generation usually
# pulled in transitively
find_package(catkin REQUIRED COMPONENTS <ros_package_dependencies> message_generation)
# ROS stuff
add_message_files(FILES
MyMessage1.msg
MyMessage2.msg
)
add_service_files(FILES
MyService.srv
)
add_action_files(FILES
MyAction.action
)
generate_messages(DEPENDENCIES std_msgs sensor_msgs actionlib_msgs)
# Specify package build info export
# Must be called before declaring any targets with add_library() or add_executable
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS roscpp nodelet
DEPENDS eigen opencv)
add_library()
add_executable()
target_link_libraries())
catkin_add_gtest()
install()
These are simple text files for specifying data structure of message.
source /opt/ros/indigo/setup.bash
mkdir ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
To build workspace:
cd ~/catkin_ws/
catkin_make
Sourcing ROS environment variables
source ~/catkin_ws/devel/setup.bash
echo $ROS_PACKAGE_PATH # make sure proper environment variables set
cd ~/catkin_ws/src
# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
cd ~/catkin_ws
catkin_make
This will create a similar structure in ~/catkin_ws/devel
as found in /opt/ros/$ROSDISTRO_NAME
Sourcing built workspace to ROS environment:
~/catkin_ws/devel/setup.bash
This will build any packages in the source space (/catkin_ws) to the build space (/catkin_ws/build)
roscd <package_name>/src
# Add/edit source files
roscd <package_name>
# Update CMakeLists.txt to reflect change to sources
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON
# Source either the `devel` or `install` space
# To source devel space:
# source ~/catkin_ws/devel/setup.bash
# To source install space:
# catkin_make install
# source ~/catkin_ws/install/setup.bash
To add a new package to a previously compiled workspace:
catkin_make --force-cmake