@@ -123,14 +123,13 @@ def _mesg(self, genre, *args, **kwargs):
123123 LEN ,
124124 genre ,
125125 ]
126- # if command_data:
127- # command.extend(command_data)
128- # if self.__class__.__name__ == "Mercury":
129- # command[2] += 1
130- # command.extend(self.crc_check(command))
131- command .extend (command_data )
132- # else:
133- command .append (ProtocolCode .FOOTER )
126+ if command_data :
127+ command .extend (command_data )
128+ if self .__class__ .__name__ == "Mercury" :
129+ command [2 ] += 1
130+ command .extend (self .crc_check (command ))
131+ else :
132+ command .append (ProtocolCode .FOOTER )
134133
135134 real_command = self ._flatten (command )
136135 has_reply = kwargs .get ("has_reply" , False )
@@ -696,30 +695,42 @@ def set_pwm_output(self, channel, frequency, pin_val):
696695 """
697696 return self ._mesg (ProtocolCode .SET_PWM_OUTPUT , channel , [frequency ], pin_val )
698697
699- def get_gripper_value (self , _type = None ):
698+ def get_gripper_value (self , gripper_type = None ):
700699 """Get the value of gripper.
700+
701+ Args:
702+ gripper_type (int): default 1
703+ 1: Adaptive gripper
704+ 3: Parallel gripper
705+ 4: Flexible gripper
701706
702707 Return:
703708 gripper value (int)
704709 """
705- if _type is None :
710+ self .calibration_parameters (class_name = self .__class__ .__name__ , gripper_type = gripper_type )
711+ if gripper_type is None :
706712 return self ._mesg (ProtocolCode .GET_GRIPPER_VALUE , has_reply = True )
707713 else :
708- return self ._mesg (ProtocolCode .GET_GRIPPER_VALUE , _type , has_reply = True )
714+ return self ._mesg (ProtocolCode .GET_GRIPPER_VALUE , gripper_type , has_reply = True )
709715
710716
711- def set_gripper_state (self , flag , speed , _type ):
717+ def set_gripper_state (self , flag , speed , _type_1 = None ):
712718 """Set gripper switch state
713719
714720 Args:
715- flag (int): 0 - open, 1 - close, 10 - release
721+ flag (int): 0 - open, 1 - close, 254 - release
716722 speed (int): 1 ~ 100
717- """
718- self .calibration_parameters (class_name = self .__class__ .__name__ , flag = flag , speed = speed , _type = _type )
719- if _type is None :
723+ _type_1 (int): default 1
724+ 1 : Adaptive gripper. default to adaptive gripper
725+ 2 : 5 finger dexterous hand
726+ 3 : Parallel gripper, this parameter can be omitted
727+ 4 : Flexible gripper
728+ """
729+ self .calibration_parameters (class_name = self .__class__ .__name__ , flag = flag , speed = speed , _type_1 = _type_1 )
730+ if _type_1 is None :
720731 return self ._mesg (ProtocolCode .SET_GRIPPER_STATE , flag , speed )
721732 else :
722- return self ._mesg (ProtocolCode .SET_GRIPPER_STATE , flag , speed , _type )
733+ return self ._mesg (ProtocolCode .SET_GRIPPER_STATE , flag , speed , _type_1 )
723734
724735
725736 def set_gripper_value (self , gripper_value , speed , gripper_type = None ):
@@ -728,9 +739,13 @@ def set_gripper_value(self, gripper_value, speed, gripper_type=None):
728739 Args:
729740 gripper_value (int): 0 ~ 100
730741 speed (int): 1 ~ 100
742+ gripper_type (int): default 1
743+ 1: Adaptive gripper
744+ 3: Parallel gripper, this parameter can be omitted
745+ 4: Flexible gripper
731746 """
732747 if gripper_type is not None :
733- self .calibration_parameters (class_name = self .__class__ .__name__ , gripper_value = gripper_value , speed = speed , gripper_type = gripper_type )
748+ self .calibration_parameters (class_name = self .__class__ .__name__ , gripper_value = gripper_value , speed = speed , _type = gripper_type )
734749 return self ._mesg (ProtocolCode .SET_GRIPPER_VALUE , gripper_value , speed , gripper_type )
735750 else :
736751 return self ._mesg (ProtocolCode .SET_GRIPPER_VALUE , gripper_value , speed )
0 commit comments