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

What arguments for rospy.ServiceProxy ?

asked 2017-06-02 05:27:21 -0600

mattMGN gravatar image


I would want to call a service using python. Currently this command line is working :

rosservice call /camera/start_capture

but I can't figure out how to do the same thing with python. I already tried this without succes :


Any idea ?


edit retag flag offensive close merge delete



Hi, the second argument in SeriveProxy should be your service class associated with the name '/camera/start_capture'

yzheng0310 gravatar image yzheng0310  ( 2017-06-02 19:12:40 -0600 )edit

from command line, use rosservice info /camera/start_capture to find the service type from the service type, find out the input/output of this service when call this using python: thisService = rospy.ServiceProxy('/camera/start_capture', type) result = thisService(input) #input is to trigger the server, result is the output/acknowledgement from server.

googooroom gravatar image googooroom  ( 2021-08-11 19:46:13 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-04 11:03:03 -0600

updated 2017-08-04 14:26:55 -0600

NEngelhard gravatar image

As @yzheng0310 said, you must use the class that defines your service.

Let's suppose that the service used by /camera/start_capture is a StartCatpure that is defined in your package, and let's suppose that your package is named my_package.

In this case you would do the following:

import rospy 
from my_package.srv import StartCatpure
start_capture = rospy.ServiceProxy('start_capture_node', StartCapture)

Now, let's call the service. In this case, supposing that the service doesn't accept parameters:


You can check the ROS Tutorial Writing a SImple Publisher and Subscriber in Python that explains step by step.

edit flag offensive delete link more



(Small hint: use the 101010-Button to format code)

NEngelhard gravatar image NEngelhard  ( 2017-08-04 14:27:26 -0600 )edit

Question Tools


Asked: 2017-06-02 05:27:21 -0600

Seen: 6,722 times

Last updated: Aug 04 '17