Ask Your Question
-1

connect python to c++

asked 2015-08-13 17:03:45 -0600

Fi gravatar image

Hi I am not sure how to use the variables and function of a python code (.py) in a cpp file?

edit retag flag offensive close merge delete

Comments

This is kind of a big question, and this forum is specifically for ROS support. Can you describe how you want to use Python and C++ with ROS?

ahendrix gravatar image ahendrix  ( 2015-08-13 20:15:38 -0600 )edit

I have two code in ROS One written by C++ and another one with python. I want to use in ROS c++ code the output of python code(variables, functions) as input of C++ program!

Fi gravatar image Fi  ( 2015-08-14 14:30:16 -0600 )edit

I think this kind of questions would be better in stackoverflow, but if you are flexible about the solution, publishing/subscribing is the way to go.

Mehdi. gravatar image Mehdi.  ( 2015-08-17 03:56:07 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2015-08-17 02:31:54 -0600

ahendrix gravatar image

Usually, if you have two nodes written in different languages, you can have one publish its output to a topic, and have the other node subscribe to that topic.

Trying to call Python functions from C++ is possible, but it's not usually a good idea due to the complexity and the overhead involved.

If you want a more specific answer, you'll need to provide more specifics (and preferably examples) of what you want to do.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-08-13 17:03:45 -0600

Seen: 898 times

Last updated: Aug 17 '15