ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS CPP Wrapper for existing Python

asked 2015-04-27 16:01:02 -0600

GGabria gravatar image

Hi All,

I have a package that contains a couple of python files that provides utilities functionality and some defines.

A class from this can then be "imported" into another python project and used as required.

I would like to provide the same functionality for C++ projects.

What would be the best way to do this with minimum code duplication?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-28 03:00:26 -0600

tfoote gravatar image

Exposing python code inside a c++ is not recommended. Most people trying to do this will do something like exec'ing a child process and parsing the command line output if really necessary. But that's very brittle.

The ROS style approach would be to create messages which provide the "defines" or constants to all languages. And expose the functionality as a ROS service or matching pub/sub topics which can then transition from c++ to python and back.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-04-27 16:01:02 -0600

Seen: 161 times

Last updated: Aug 28 '15