Proper ROS way to call python from C++

asked 2016-11-01 19:28:33 -0600

curranw gravatar image

updated 2016-11-01 19:29:24 -0600

I have a large python library that interfaces with sklearn, and a large C++ library that interfaces with the robot, runs ROS, and has a lot of other robot-esque functionality. I'd like to use my python library in my C++ library. Rather than mess with the Python.h, I figured ROS would be a much cleaner interface.

I used services to connect to my python library, but they are simply too slow. This makes me think service calls may be the wrong way to do this. I set the persistent flag to true. That helped, but still isn't quite fast enough.

I'm in the process of switching to messages, but it's a major hack, since I'm essentially calling a ros::spinOnce after every publication to force the "hand shaking" and playing too much with callbacks. Gross.

What are the ways to make service calls faster? Is the persistent flag it? Should I just be using the Python.h infrastructure?

edit retag flag offensive close merge delete