Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 import rospy
00038
00039 from abs_hand_command import AbsractHandCommand
00040
00041
00042 class GripperCommand(AbsractHandCommand):
00043 '''
00044 Following Command design pattern, this class represents an abstract
00045 command for hand classes of NEXTAGE OPEN.
00046
00047 NOTE: 1/31/2014 TODO: Only right hand is implemented for now.
00048 '''
00049
00050
00051 GRIPPER_CLOSE = 'close'
00052 GRIPPER_OPEN = 'open'
00053 GRIPPER_DANGER = 'danger'
00054
00055 def __init__(self, hands, hand, dio_pins):
00056 super(GripperCommand, self).__init__(hands, hand, dio_pins)
00057
00058 def _assign_dio_names(self, dio_pins):
00059 '''
00060 @see abs_hand_command.AbsractHandCommand._assign_dio_names
00061 '''
00062 self._DIO_VALVE_L_1 = dio_pins[0]
00063 self._DIO_VALVE_L_2 = dio_pins[1]
00064 self._DIO_VALVE_R_1 = dio_pins[2]
00065 self._DIO_VALVE_R_2 = dio_pins[3]
00066
00067 def execute(self, operation):
00068 '''
00069 @see abs_hand_command.AbsractHandCommand.execute
00070 '''
00071 dout = []
00072 mask_l = [self._DIO_VALVE_L_1, self._DIO_VALVE_L_2]
00073 mask_r = [self._DIO_VALVE_R_1, self._DIO_VALVE_R_2]
00074 if self.GRIPPER_CLOSE == operation:
00075 if self._hands.HAND_L == self._hand:
00076 dout = [self._DIO_VALVE_L_1]
00077
00078 elif self._hands.HAND_R == self._hand:
00079 dout = [self._DIO_VALVE_R_1]
00080 elif self.GRIPPER_OPEN == operation:
00081 if self._hands.HAND_L == self._hand:
00082 dout = [self._DIO_VALVE_L_2]
00083 elif self._hands.HAND_R == self._hand:
00084 dout = [self._DIO_VALVE_R_2]
00085 mask = None
00086 if self._hands.HAND_L == self._hand:
00087 mask = mask_l
00088 elif self._hands.HAND_R == self._hand:
00089 mask = mask_r
00090 return self._hands._dio_writer(dout, mask)