Understanding the catkin, CMakeList, setup.py build flow in Python

asked 2014-10-07 08:46:24 -0500

alainh gravatar image

I'm running Hydro on a Beaglebone Black (since there are no Debian builds for the embedded platform I hacked together my own, the details of which you can find here for reference).

I've been trying to build a simple Python script which publishes IMU data from an I2C interface and uses the the sensor_msgs and geometry_msgs libraries. Currently my project structure is as followed:

|-- myscript.py 
|-- package.xml
|-- CMakeList.txt
|-- setup.py
+-- src
    +-- mypkg
        +-- myscript.py

In my actual code mypkg is named imuraw_gy88.


        This package reads raw {accelero/gryo/magno}meter data from the GY88 and publishes it
    <maintainer email="email">name</maintainer>






## I stripped all comments from this one for readability

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS
  rospy sensor_msgs geometry_msgs 

#  INCLUDE_DIRS include
#  LIBRARIES imuraw_gy88
  CATKIN_DEPENDS rospy sensor_msgs geometry_msgs
#  DEPENDS system_lib




from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
        package_dir={'': 'src'}


myscript.py (imuraw_gy88.py)

""" Only including the header for this example as all the other code is application specific """
import rospy
import sensor_msgs.msg # IMU data type
from std_msgs.msg import Header # Header to contain timestamp information
from geometry_msgs.msg import Vector3 # Standard Vector form for ROS

In its current state, using catkin_make_isolated --install --pkg mypkg does cause my package to build. However, what I'm lacking is an understand of whats going on exactly.


  • There appears to be some redundancy with setup.py. What is it doing? What is it responsible for?
  • Does package.xml actually help the compiler understand the dependencies? Or is it just there for documentation?
  • Why does the Python bits of this need to be run through catkin_make? In particular, how does CMakeList tell Python how to link up dependencies to other packages?
  • What is the correct project structure and workflow for using catkin + Python in ROS?

I would greatly appreciate any guide on how exactly this build system works!

Thank you for your time. :)

edit retag flag offensive close merge delete