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

Revision history [back]

When creating a service proxy the arguments to the function are name and type

rospy.ServiceProxy(service_name, service_type)

The service_name is the name you see in the list when you call rosservice list. The service type is the result you get when you call rosservice type service_name.

What you actually want to do is this:

clear_bg = rospy.ServiceProxy('clear', std_srvs.srv.Empty)

The above line of code basically connects to the service with name clear and type std_srvs.srv.Empty. If you look at the turtlesim documentation page (http://ros.org/wiki/turtlesim) you can see that the service is listed as:

clear (std_srvs/Empty)

You may also want to throw in a wait for service so that you don't get an error when trying to call the service call in a node that is roslaunched.

rospy.wait_for_service('clear')

You can read more about services here: http://ros.org/wiki/rospy/Overview/Services

This is also explained here: http://ros.org/wiki/ROS/Tutorials/WritingServiceClient(python)