| Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials. |
Writing a ROS Python Makefile
Description: I know what you're saying: "Python... Makefile?" Believe it or not, you do need Makefile (and CMakeLists), even if you just hack Python all day.Tutorial Level: BEGINNER
Writing a ROS Python Makefile
Description: I know what you're saying: "Python... Makefile?" Believe it or not, you do need Makefile (and CMakeLists), even if you just hack Python all day.
These build files are fairly simple, but they provide important functionality such as:
- autogenerating message and service code
- running tests
The test functionality is especially important as we have the ability to run tests on your package plus every package that depends on it (rospack pkg test), which is very important for finding regressions prior to checkin.
These build files are not difficult to write. In fact, we have an automated tool that will create a all the necessary build files for you:
roscreate-pkg my_pkg rospy
This will create my_pkg and add in a dependency on rospy so that you can use in it your code.
If you want to write the necessary build files by hand, here's what you need:
1. Makefile
Your Makefile only needs to be one line:
mypackage/Makefile
include $(shell rospack find mk)/cmake.mk
This loads up our cmake definitions, which ensure our builds are cross-platform.
2. CMakeLists.txt
You also need to provide the CMakeLists file, which is also fairly simple. Here is an example for a Package that has Messages, Services, and tests:
mypackage/CMakeLists.txt
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
rosbuild_genmsg()
rosbuild_gensrv()
rosbuild_add_rostest(test/talker-listener-test.launch)Feel free to omit the rosbuild_genmsg/rosbuild_gensrv/rosbuild_add_rostest lines as appropriate.






