Go to the documentation of this file.00001 import roslib; roslib.load_manifest('iri_wam_smach')
00002 import rospy
00003 import smach
00004 import smach_ros
00005
00006 from iri_wam_common_msgs.srv import wamdriver
00007 from pprint import pprint
00008
00009 class WamHold(smach.State):
00010 """
00011 HOLDON or HOLDOFF WAM ARM
00012
00013 @type hold_service: string
00014 @param hold_service: URI of wam_wrapper hold service
00015 @type call : integer [input_key]
00016 @param call : 0 -> hold ON, 1 -> hold OFF
00017
00018 """
00019 def __init__(self, hold_service):
00020 smach.State.__init__(self,
00021 outcomes = ['success', 'fail'],
00022 input_keys = ['call'],
00023 output_keys = [])
00024
00025 self.hold_service = hold_service
00026
00027 def execute(self, userdata):
00028 if (userdata.call == None):
00029 rospy.logwarn("Empty call received. 0 -> hold ON, 1 -> hold OFF")
00030 return 'fail'
00031
00032 try:
00033 handler = rospy.ServiceProxy(self.hold_service, wamdriver)
00034 response = handler(userdata.call)
00035
00036 if (response):
00037 pprint(response.success)
00038
00039 except rospy.ServiceException, e:
00040 return 'fail'
00041
00042 return 'success'