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

How to use ROS service to call a C++ function from python

asked 2019-04-16 19:31:28 -0500

Tawfiq Chowdhury gravatar image

I am working on a pick and place project using moveit. My code is in Python. In moveit, I did not find any option for gripper open/close functionality in python so I am using an external C++ file to do that and the C++ file has the functions to open and close the gripper. I heard that I can do so using ROS service but I do not exactly know how. Can anyone refers to a tutorial or provide me an example? What I want is I need to call a function to open or close the gripper from my python code.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-04-17 03:32:37 -0500

Isha Dijcks gravatar image

There are 2 things that come to mind:

non-ros answer

You can use a library to wrap you C++ functions so they are accessible with Python as seen in this post here.

ros answer

You could write a service on the C++ node and a client on the Python node that communicate with each other.

The easiest way to get started is to check the following tutorials on Services that are written in C++ and Python and combine them to work for your problem:

http://wiki.ros.org/ROS/Tutorials/Wri...

http://wiki.ros.org/ROS/Tutorials/Wri...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-04-16 19:31:28 -0500

Seen: 2,051 times

Last updated: Apr 17 '19