Importing C++ module in python

asked 2018-03-01 09:53:10 -0500

bxl gravatar image

I'm trying to import a C++ module in my python script.
My C++ nodule has a class with NodeHandle and I'm following this tutorial (item 2)

However, this class is wrappred in a `namespace' which is not recognized and lead to crash node:

pf = pose_follower.HectorPathFollower()

namespace pose_follower {
 class HectorPathFollower
edit retag flag offensive close merge delete


I don't know too much about calling C++ code from Python but it's definitely an advanced and nonstandard way of doing things in ROS. Are you sure it's not better to go with a more standard design of separate C++ and Python nodes that talk to each other over topics and services?

jdlangs gravatar image jdlangs  ( 2018-03-01 13:47:43 -0500 )edit

@jdlangs The code is provided as a c++ lib and I`m trying to implement in python a node that uses it. The idea of coding nodes that exchange data over services and topics don't apply in this case.

bxl gravatar image bxl  ( 2018-03-01 14:01:52 -0500 )edit

Well, the usual thing to do would be to make a small c++ node that does nothing but input your data to the library and output the result to be used in your python code. But you would know best if doing that is more painful than just using Python directly.

jdlangs gravatar image jdlangs  ( 2018-03-01 14:44:48 -0500 )edit