Ask Your Question
1

What arguments for rospy.ServiceProxy ?

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

mattMGN gravatar image

Hello,

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 :

rospy.ServiceProxy('/camera/start_capture',True)

Any idea ?

Matt

edit retag flag offensive close merge delete

Comments

1

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

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

1 Answer

Sort by ยป oldest newest most voted
1

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:

start_capture()

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

Comments

1

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

NEngelhard gravatar imageNEngelhard ( 2017-08-04 14:27:26 -0600 )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

Stats

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

Seen: 2,278 times

Last updated: Aug 04 '17