@@ -787,41 +787,63 @@ def calibration_parameters(**kwargs):
787787 "The range of 'torque_value' in {} is 100 ~ 300, but the received value is {}" .format (parameter ,
788788 torque_value ))
789789
790- elif parameter == "gripper_speed" :
791- gripper_id , speed = value
792- if not isinstance (gripper_id , int ) or not isinstance (speed , int ):
793- raise MyCobot320DataException (
794- "Both 'gripper_id' and 'speed' in {} must be integers" .format (parameter ))
795- if gripper_id < 1 or gripper_id > 254 :
796- raise MyCobot320DataException (
797- "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
798- gripper_id ))
799- if speed < 1 or torque_value > 100 :
800- raise MyCobot320DataException (
801- "The range of 'speed' in {} is 1 ~ 100, but the received value is {}" .format (parameter ,
802- speed ))
803- elif parameter == "set_gripper_args" :
804- if len (value ) != 3 :
805- raise ValueError (f"Expected 3 arguments, but got { len (value )} " )
806- gripper_id , address , data = value
807- if not isinstance (gripper_id , int ) or not isinstance (address , int ) or not isinstance (data , int ):
808- raise MyCobot320DataException (
809- "All arguments in {} must be integers" .format (parameter ))
810- if gripper_id < 1 or gripper_id > 254 :
811- raise MyCobot320DataException (
812- "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
813- gripper_id ))
814- 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 ,
815- 36 ,
816- 37 , 38 , 39 , 40 , 42 , 44 ]
817- if address < 1 or address > 44 :
790+ elif parameter == "gripper_speed" :
791+ gripper_id , speed = value
792+ if not isinstance (gripper_id , int ) or not isinstance (speed , int ):
793+ raise MyCobot320DataException (
794+ "Both 'gripper_id' and 'speed' in {} must be integers" .format (parameter ))
795+ if gripper_id < 1 or gripper_id > 254 :
796+ raise MyCobot320DataException (
797+ "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
798+ gripper_id ))
799+ if speed < 1 or speed > 100 :
800+ raise MyCobot320DataException (
801+ "The range of 'speed' in {} is 1 ~ 100, but the received value is {}" .format (parameter ,
802+ 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+ )
810+ elif parameter == "set_gripper_args" :
811+ gripper_id , address , data = value
812+ if not isinstance (gripper_id , int ) or not isinstance (address , int ):
813+ raise MyCobot320DataException (
814+ "All arguments in {} must be integers" .format (parameter ))
815+ if gripper_id < 1 or gripper_id > 254 :
816+ raise MyCobot320DataException (
817+ "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
818+ 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 :
823+ raise MyCobot320DataException (
824+ "The range of 'address' in {} is 1 ~ 48, but the received value is {}" .format (parameter ,
825+ address ))
826+ if address in invalid_addresses :
827+ raise MyCobot320DataException (
828+ "'address' in {} cannot be one of the following values: {}, but the received value is {}" .format (
829+ parameter , invalid_addresses , address ))
830+ print ('data:' , data )
831+ if isinstance (data , list ):
832+ # 处理 data 为列表的情况
833+ if len (data ) != 6 :
818834 raise MyCobot320DataException (
819- "The range of 'address' in {} is 1 ~ 44, but the received value is {}" .format (parameter ,
820- address ))
821- if address in invalid_addresses :
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 ):
822844 raise MyCobot320DataException (
823- "'address' in {} cannot be one of the following values: {}, but the received value is {} " .format (
824- parameter , invalid_addresses , address ) )
845+ "The parameter {} must be an integer " .format (data )
846+ )
825847 # 根据 address 来处理 value
826848 if address in [3 , 43 ]:
827849 if data < 1 or data > 254 :
@@ -849,24 +871,24 @@ def calibration_parameters(**kwargs):
849871 "Error in parameter '{}': The range of 'value' for address={} is 0 ~ 100, but the received value is {}" .format (
850872 parameter , address , data ))
851873
852- elif parameter == "get_gripper_args" :
853- gripper_id , address = value
854- if not isinstance (gripper_id , int ) or not isinstance (address , int ):
855- raise MyCobot320DataException (
856- "All arguments in {} must be integers" .format (parameter ))
857- if gripper_id < 1 or gripper_id > 254 :
858- raise MyCobot320DataException (
859- "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
860- gripper_id ))
861- invalid_addresses = [5 , 6 , 10 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 23 , 25 , 29 , 30 , 31 , 34 , 35 , 41 , 43 ]
862- if address < 1 or address > 44 :
863- raise MyCobot320DataException (
864- "The range of 'address' in {} is 1 ~ 44, but the received value is {}" .format (parameter ,
865- address ))
866- if address in invalid_addresses :
867- raise MyCobot320DataException (
868- "'address' in {} cannot be one of the following values: {}, but the received value is {}" .format (
869- parameter , invalid_addresses , address ))
874+ elif parameter == "get_gripper_args" :
875+ gripper_id , address = value
876+ if not isinstance (gripper_id , int ) or not isinstance (address , int ):
877+ raise MyCobot320DataException (
878+ "All arguments in {} must be integers" .format (parameter ))
879+ if gripper_id < 1 or gripper_id > 254 :
880+ raise MyCobot320DataException (
881+ "The range of 'gripper_id' in {} is 1 ~ 254, but the received value is {}" .format (parameter ,
882+ gripper_id ))
883+ invalid_addresses = [5 , 6 , 10 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 23 , 25 , 29 , 30 , 31 , 34 , 35 , 41 , 43 ]
884+ if address < 1 or address > 44 :
885+ raise MyCobot320DataException (
886+ "The range of 'address' in {} is 1 ~ 44, but the received value is {}" .format (parameter ,
887+ address ))
888+ if address in invalid_addresses :
889+ raise MyCobot320DataException (
890+ "'address' in {} cannot be one of the following values: {}, but the received value is {}" .format (
891+ parameter , invalid_addresses , address ))
870892 elif class_name in ["MechArm" , "MechArmSocket" ]:
871893 public_check (parameter_list , kwargs , robot_limit , class_name , MechArmDataException )
872894 elif class_name in ["MechArm270" , "MechArmSocket" ]:
@@ -1154,7 +1176,7 @@ def calibration_parameters(**kwargs):
11541176 elif parameter == 'gripper_type' :
11551177 check_0_or_1 (parameter , value , [1 , 3 , 4 ], value_type , MyPalletizer260DataException , int )
11561178 elif parameter == '_type_1' :
1157- check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 ], value_type , MyPalletizer260DataException , int )
1179+ check_0_or_1 (parameter , value , [1 , 2 , 3 , 4 , 5 ], value_type , MyPalletizer260DataException , int )
11581180 # if value not in [0, 1, 10]:
11591181 # raise exception_class("The data supported by parameter {} is 0 or 1 or 10, but the received value is {}".format(parameter, value))
11601182 elif parameter == 'gripper_value' :
0 commit comments