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

connect python to c++

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

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 -0500 )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 -0500 )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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
5

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

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

Question Tools

1 follower

Stats

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

Seen: 1,050 times

Last updated: Aug 17 '15