@@ -550,9 +550,11 @@ def calibration_parameters(**kwargs):
550550 elif parameter == 'flag' :
551551 check_0_or_1 (parameter , value , [0 , 1 , 254 ], value_type , MyCobot280DataException , int )
552552 elif parameter == 'gripper_type' :
553- check_0_or_1 (parameter , value , [1 , 3 , 4 ], value_type , MyCobot280DataException , int )
553+ if value is not None :
554+ check_0_or_1 (parameter , value , [1 , 3 , 4 , 5 ], value_type , MyCobot280DataException , int )
554555 elif parameter == '_type_1' :
555- check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 ], value_type , MyCobot280DataException , int )
556+ if value is not None :
557+ check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 , 5 ], value_type , MyCobot280DataException , int )
556558 elif parameter == 'gripper_value' :
557559 check_value_type (parameter , value_type , MyCobot280DataException , int )
558560 if value < 0 or value > 100 :
@@ -636,6 +638,9 @@ def calibration_parameters(**kwargs):
636638 value ))
637639 elif parameter == 'end_direction' :
638640 check_0_or_1 (parameter , value , [1 , 2 , 3 ], value_type , MyCobot280DataException , int )
641+ elif parameter == 'is_torque' :
642+ if value is not None :
643+ check_0_or_1 (parameter , value , [0 , 1 ], value_type , MyCobot280DataException , int )
639644 elif class_name in ["MyCobot320" , "MyCobot320Socket" ]:
640645 for parameter in parameter_list [1 :]:
641646 value = kwargs .get (parameter , None )
@@ -800,76 +805,54 @@ def calibration_parameters(**kwargs):
800805 raise MyCobot320DataException (
801806 "The range of 'speed' in {} is 1 ~ 100, but the received value is {}" .format (parameter ,
802807 speed ))
803- elif parameter == "joint_id" :
804- check_value_type (parameter , value_type , MyCobot320DataException , int )
805- if not 0 <= value <= 6 :
806- raise MyCobot320DataException (
807- "speed value not right, should be 1 ~ 100, the received speed is %s"
808- % value
809- )
808+
810809 elif parameter == "set_gripper_args" :
810+ if len (value ) != 3 :
811+ raise ValueError (f"Expected 3 arguments, but got { len (value )} " )
811812 gripper_id , address , data = value
812- if not isinstance (gripper_id , int ) or not isinstance (address , int ):
813+ if not isinstance (gripper_id , int ) or not isinstance (address , int ) or not isinstance ( data , int ) :
813814 raise MyCobot320DataException (
814815 "All arguments in {} must be integers" .format (parameter ))
815816 if gripper_id < 1 or gripper_id > 254 :
816817 raise MyCobot320DataException (
817818 "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
818819 gripper_id ))
819- invalid_addresses = [1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 22 , 24 , 26 , 27 , 28 , 32 , 33 ,
820- 36 ,
821- 37 , 38 , 39 , 40 , 42 , 44 ]
822- if address < 1 or address > 48 :
820+ invalid_addresses = [1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 , 12 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 22 , 24 , 26 , 28 , 33 , 34 , 35 ,
821+ 40 , 42 , 44 ]
822+ if address < 1 or address > 44 :
823823 raise MyCobot320DataException (
824- "The range of 'address' in {} is 1 ~ 48 , but the received value is {}" .format (parameter ,
824+ "The range of 'address' in {} is 1 ~ 44 , but the received value is {}" .format (parameter ,
825825 address ))
826826 if address in invalid_addresses :
827827 raise MyCobot320DataException (
828828 "'address' in {} cannot be one of the following values: {}, but the received value is {}" .format (
829829 parameter , invalid_addresses , address ))
830- print ('data:' , data )
831- if isinstance (data , list ):
832- # 处理 data 为列表的情况
833- if len (data ) != 6 :
830+ # 根据 address 来处理 value
831+ if address in [3 , 43 ]:
832+ if data < 1 or data > 254 :
834833 raise MyCobot320DataException (
835- "data must be a list of length 6。"
836- )
837- for index , value in enumerate (data ):
838- if not (0 <= value <= 100 ):
839- raise MyCobot320DataException (
840- "Each value in the data list must be between 0 and 100. Error index {}: The received value is {}" .format (index , value )
841- )
842- else :
843- if not isinstance (data , int ):
834+ "Error in parameter '{}': The range of 'value' for address={} is 1 ~ 254, but the received value is {}" .format (
835+ parameter , address , data ))
836+ elif address == 10 :
837+ if data not in [0 , 1 ]:
844838 raise MyCobot320DataException (
845- "The parameter {} must be an integer" .format (data )
846- )
847- # 根据 address 来处理 value
848- if address in [3 , 43 ]:
849- if data < 1 or data > 254 :
850- raise MyCobot320DataException (
851- "Error in parameter '{}': The range of 'value' for address={} is 1 ~ 254, but the received value is {}" .format (
852- parameter , address , data ))
853- elif address == 10 :
854- if data not in [0 , 1 ]:
855- raise MyCobot320DataException (
856- "Error in parameter '{}': Value for address={} must be 0 or 1, but the received value is {}" .format (
857- parameter , address , data ))
858- elif address in [25 ]:
859- if data < 0 or data > 254 :
860- raise MyCobot320DataException (
861- "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 254, but the received value is {}" .format (
862- parameter , address , data ))
863- elif address in [21 , 23 ]:
864- if data < 0 or data > 16 :
865- raise MyCobot320DataException (
866- "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 16, but the received value is {}" .format (
867- parameter , address , data ))
868- elif address == 41 :
869- if data < 0 or data > 100 :
870- raise MyCobot320DataException (
871- "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 100, but the received value is {}" .format (
872- parameter , address , data ))
839+ "Error in parameter '{}': Value for address={} must be 0 or 1, but the received value is {}" .format (
840+ parameter , address , data ))
841+ elif address in [25 ]:
842+ if data < 0 or data > 254 :
843+ raise MyCobot320DataException (
844+ "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 254, but the received value is {}" .format (
845+ parameter , address , data ))
846+ elif address in [21 , 23 ]:
847+ if data < 0 or data > 16 :
848+ raise MyCobot320DataException (
849+ "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 16, but the received value is {}" .format (
850+ parameter , address , data ))
851+ elif address == 41 :
852+ if data < 0 or data > 100 :
853+ raise MyCobot320DataException (
854+ "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 100, but the received value is {}" .format (
855+ parameter , address , data ))
873856
874857 elif parameter == "get_gripper_args" :
875858 gripper_id , address = value
@@ -880,7 +863,8 @@ def calibration_parameters(**kwargs):
880863 raise MyCobot320DataException (
881864 "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
882865 gripper_id ))
883- invalid_addresses = [5 , 6 , 10 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 23 , 25 , 29 , 30 , 31 , 34 , 35 , 41 , 43 ]
866+ invalid_addresses = [3 , 5 , 6 , 10 , 11 , 13 , 15 , 17 , 19 , 21 , 23 , 25 , 27 , 29 , 30 , 31 , 32 , 36 , 37 ,
867+ 38 , 39 , 41 , 43 ]
884868 if address < 1 or address > 44 :
885869 raise MyCobot320DataException (
886870 "The range of 'address' in {} is 1 ~ 44, but the received value is {}" .format (parameter ,
@@ -921,11 +905,14 @@ def calibration_parameters(**kwargs):
921905 % value
922906 )
923907 elif parameter == 'flag' :
924- check_0_or_1 (parameter , value , [0 , 1 , 254 ], value_type , MechArmDataException , int )
908+ if value is not None :
909+ check_0_or_1 (parameter , value , [0 , 1 , 254 ], value_type , MechArmDataException , int )
925910 elif parameter == 'gripper_type' :
926- check_0_or_1 (parameter , value , [1 , 3 , 4 ], value_type , MechArmDataException , int )
911+ if value is not None :
912+ check_0_or_1 (parameter , value , [1 , 3 , 4 , 5 ], value_type , MechArmDataException , int )
927913 elif parameter == '_type_1' :
928- check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 ], value_type , MechArmDataException , int )
914+ if value is not None :
915+ check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 , 5 ], value_type , MechArmDataException , int )
929916 # if value not in [0, 1, 10]:
930917 # raise exception_class("The data supported by parameter {} is 0 or 1 or 10, but the received value is {}".format(parameter, value))
931918 elif parameter == 'gripper_value' :
@@ -1010,6 +997,9 @@ def calibration_parameters(**kwargs):
1010997 value ))
1011998 elif parameter == 'end_direction' :
1012999 check_0_or_1 (parameter , value , [1 , 2 , 3 ], value_type , MechArmDataException , int )
1000+ elif parameter == 'is_torque' :
1001+ if value is not None :
1002+ check_0_or_1 (parameter , value , [0 , 1 ], value_type , MyCobot280DataException , int )
10131003 elif class_name in ["MyArm" , "MyArmSocket" ]:
10141004 public_check (parameter_list , kwargs , robot_limit , class_name , MyArmDataException )
10151005 for parameter in parameter_list [1 :]:
@@ -1269,7 +1259,8 @@ def calibration_parameters(**kwargs):
12691259 elif parameter in ['servo_id_pdi' , 'encode_id' ]:
12701260 check_value_type (parameter , value_type , MyPalletizer260DataException , int )
12711261 if value < 1 or (value > 4 and value != 7 ):
1272- raise MyPalletizer260DataException ("The range of id is 1 ~ 4 or 7, but the received is {}" .format (value ))
1262+ raise MyPalletizer260DataException (
1263+ "The range of id is 1 ~ 4 or 7, but the received is {}" .format (value ))
12731264 elif parameter == "torque" :
12741265 torque_min = 150
12751266 torque_max = 980
0 commit comments