File tree Expand file tree Collapse file tree 4 files changed +28
-13
lines changed Expand file tree Collapse file tree 4 files changed +28
-13
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ find_package(PythonLibs REQUIRED) # sets ${PYTHON_INCLUDE_DIRS}
18
18
## Uncomment this if the package has a setup.py. This macro ensures
19
19
## modules and global scripts declared therein get installed
20
20
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
21
- # catkin_python_setup()
21
+ catkin_python_setup () # this sets up the path /devel/lib/python2.7/dist-packages/boostpy_test
22
22
23
23
24
24
@@ -54,6 +54,10 @@ include_directories(
54
54
add_library (mycpplib SHARED
55
55
src/mycpplib.cpp
56
56
)
57
+ # change output directory, so python can find the module
58
+ set_target_properties (mycpplib PROPERTIES
59
+ LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX} /${CATKIN_PACKAGE_PYTHON_DESTINATION}
60
+ )
57
61
58
62
target_link_libraries (mycpplib
59
63
${catkin_LIBRARIES}
Original file line number Diff line number Diff line change @@ -7,3 +7,13 @@ This page looks like a very nice and detailed tutorial: https://www.preney.ca/pa
7
7
8
8
Maybe even better:
9
9
https://github.com/ethz-asl/Schweizer-Messer/wiki/Adding-boost::python-exports-to-your-ROS-package
10
+
11
+ Form http://wiki.ros.org/catkin/CMakeLists.txt :
12
+ 7.2 Custom output directory
13
+ While the default output directory for executables and libraries is usual set to a reasonable
14
+ value it must be customized in certain cases. I.e. a library containing Python bindings must be
15
+ placed in a different folder to be importable in Python:
16
+
17
+ set_target_properties(python_module_library PROPERTIES
18
+ LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
19
+ )
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
-
4
- import rospy
5
-
6
- import sys
7
- # TODO: this is ugly... can this be set using cmake?
8
- sys .path .append ("/home/felix/ws/ros/devel/lib" )
9
-
10
- import libmycpplib as cpp
3
+ import boostpy_test .libmycpplib as cpp
11
4
12
5
# this is the equivalent to `main()` in c++
13
6
if __name__ == '__main__' :
14
- rospy .init_node ('use_cpplib' )
15
-
16
7
cpp .hello ()
17
-
18
- #rospy.spin()
Original file line number Diff line number Diff line change
1
+ ## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD
2
+
3
+ from distutils .core import setup
4
+ from catkin_pkg .python_setup import generate_distutils_setup
5
+
6
+ # fetch values from package.xml
7
+ setup_args = generate_distutils_setup (
8
+ packages = ['boostpy_test' ],
9
+ package_dir = {'' : 'src' },
10
+ )
11
+
12
+ setup (** setup_args )
You can’t perform that action at this time.
0 commit comments