@@ -35,8 +35,9 @@ Configure cmake
35
35
${catkin_LIBRARIES}
36
36
${Boost_LIBRARIES}
37
37
)
38
- # change output directory, so python can find the module
38
+ # change output directory, so python can find the module and avoid the 'lib'-prefix
39
39
set_target_properties(mycpplib PROPERTIES
40
+ PREFIX ""
40
41
LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
41
42
)
42
43
The last command is important because it will change the destination of the compiled library
@@ -54,11 +55,31 @@ After you compiled the package, you should be able to use the wrapped module in
54
55
cpp.hello()
55
56
56
57
58
+ Boost::Python and ROS::NodeHandle
59
+ ---------------------------------
60
+
61
+ When using ROS, there is one important thing to keep in mind: Assume you have a ROS node written
62
+ in Python, that uses some C++ code via Boost::Python.
63
+ If the C++ code needs a ` ros::NodeHandle ` , for example to fetch some parameters from the
64
+ parameter server, it will crash, because the `rospy.init_node()' does ** not** initialize roscpp!
65
+
66
+ To get around this, you need the _ MoveIt ROS planning interface_ which is available in the ROS
67
+ repos (` sudo apt-get install ros-groovy-moveit-ros-planning-interface ` ). Once installed, add
68
+ the following code to your Python node:
69
+
70
+ from moveit_ros_planning_interface._moveit_roscpp_initializer import roscpp_init
71
+ roscpp_init('node_name', [])
72
+
73
+ Now everything should work fine.
74
+
57
75
References
58
76
----------
59
77
60
78
Some references that were helpful for me in one or the other way:
61
79
80
+ * This page, that I unfortunatly only found after I figured most of it out by myself, should
81
+ explain everything...
82
+ http://wiki.ros.org/ROS/Tutorials/Using%20a%20C%2B%2B%20class%20in%20Python
62
83
* Boost::Python documentation: http://www.boost.org/doc/libs/1_57_0/libs/python/doc/index.html
63
84
* Using Boost::Python with cmake: https://www.preney.ca/paul/archives/107
64
85
* https://github.com/ethz-asl/Schweizer-Messer/wiki/Adding-boost::python-exports-to-your-ROS-package
0 commit comments