sample_service_buttons.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 
5 from std_srvs.srv import Empty
6 from std_srvs.srv import EmptyResponse
7 from std_srvs.srv import SetBool
8 from std_srvs.srv import SetBoolResponse
9 from std_srvs.srv import Trigger
10 from std_srvs.srv import TriggerResponse
11 
12 
13 class SampleServiceButtons(object):
14  def __init__(self):
15  self.services = [
16  rospy.Service('dummy/buttonA', SetBool, self._set_bool_cb),
17  rospy.Service('dummy/buttonB', SetBool, self._set_bool_cb),
18  rospy.Service('dummy/buttonC', SetBool, self._set_bool_cb),
19  rospy.Service('dummy/buttonD', Trigger, self._trigger_cb),
20  rospy.Service('dummy/buttonE', Empty, self._empty_cb),
21  rospy.Service('dummy/buttonF', Empty, self._empty_cb),
22  ]
23 
24  def _set_bool_cb(self, req):
25  rospy.loginfo('SetBool service called: req.data={}'.format(req.data))
26  return SetBoolResponse(success=True)
27 
28  def _trigger_cb(self, req):
29  rospy.loginfo('Trigger service called')
30  return TriggerResponse(success=True)
31 
32  def _empty_cb(self, req):
33  rospy.loginfo('Empty service called')
34  return EmptyResponse()
35 
36 
37 if __name__ == '__main__':
38  rospy.init_node('sample_service_buttons')
40  rospy.spin()


jsk_rqt_plugins
Author(s):
autogenerated on Sat Mar 20 2021 03:03:13