Ask Your Question

What arguments for rospy.ServiceProxy ?

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

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

1 Answer

Sort by ยป oldest newest most voted

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

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

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

Your Answer

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

Add Answer

Question Tools


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

Seen: 4,420 times

Last updated: Aug 04 '17