@@ -130,6 +130,18 @@ def _mesg(self, genre, *args, **kwargs):
130130 return r
131131 elif genre in [ProtocolCode .COBOTX_GET_ANGLE , ProtocolCode .COBOTX_GET_SOLUTION_ANGLES ]:
132132 return self ._int2angle (res [0 ])
133+ elif genre == ProtocolCode .MERCURY_ROBOT_STATUS :
134+ i = 9
135+ for i in range (9 , len (res )):
136+ if res [i ] != 0 :
137+ data = bin (res [i ])[2 :]
138+ res [i ] = []
139+ while len (data ) != 16 :
140+ data = "0" + data
141+ for j in range (16 ):
142+ if data [j ] != "0" :
143+ res [i ].append (15 - j )
144+ return res
133145 else :
134146 return res
135147 return None
@@ -353,7 +365,99 @@ def is_gripper_moving(self, mode=None):
353365 return self ._mesg (ProtocolCode .IS_GRIPPER_MOVING , mode , has_reply = True )
354366 return self ._mesg (ProtocolCode .IS_GRIPPER_MOVING , has_reply = True )
355367
356- def turn_right (self ):
357- pass
368+ def set_gripper_enabled (self , value ):
369+ """Pro adaptive gripper enable setting
370+
371+ Args:
372+ value (int):
373+ 1 : enable
374+ 0 : release
375+ """
376+ self .calibration_parameters (class_name = self .__class__ .__name__ , value = value )
377+ return self ._mesg (ProtocolCode .SET_GRIPPER_ENABLED , value )
378+
379+ def is_btn_clicked (self ):
380+ """Check if the end button has been pressed.
381+
382+ Return:
383+ 1 : pressed.
384+ 0 : not pressed.
385+ """
386+ return self ._mesg (ProtocolCode .IS_BTN_CLICKED , has_reply = True )
387+
388+ def tool_serial_restore (self ):
389+ """485 factory reset
390+ """
391+ return self ._mesg (ProtocolCode .TOOL_SERIAL_RESTORE )
392+
393+ def tool_serial_ready (self ):
394+ """Set up 485 communication
395+
396+ Return:
397+ 0 : not set
398+ 1 : Setup completed
399+ """
400+ return self ._mesg (ProtocolCode .TOOL_SERIAL_READY , has_reply = True )
401+
402+ def tool_serial_available (self ):
403+ """Read 485 buffer length
404+
405+ Return:
406+ 485 buffer length available for reading
407+ """
408+ return self ._mesg (ProtocolCode .TOOL_SERIAL_AVAILABLE , has_reply = True )
409+
410+ def tool_serial_read_data (self , data_len ):
411+ """Read fixed length data. Before reading, read the buffer length first. After reading, the data will be cleared
412+
413+ Args:
414+ data_len (int): The number of bytes to be read, range 1 ~ 45
415+ """
416+ self .calibration_parameters (class_name = self .__class__ .__name__ , data_len = data_len )
417+ return self ._mesg (ProtocolCode .TOOL_SERIAL_READ_DATA , data_len , has_reply = True )
418+
419+ def tool_serial_write_data (self , command ):
420+ """End 485 sends data, Data length range is 1 ~ 45 bytes
421+
422+ Args:
423+ command : data instructions
424+
425+ Return:
426+ number of bytes received
427+ """
428+ return self ._mesg (ProtocolCode .TOOL_SERIAL_WRITE_DATA , command , has_reply = True )
429+
430+ def tool_serial_flush (self ):
431+ """Clear 485 buffer
432+ """
433+ return self ._mesg (ProtocolCode .TOOL_SERIAL_FLUSH )
434+
435+ def tool_serial_peek (self ):
436+ """View the first data in the buffer, the data will not be cleared
437+
438+ Return:
439+ 1 byte data
440+ """
441+ return self ._mesg (ProtocolCode .TOOL_SERIAL_PEEK , has_reply = True )
442+
443+ def tool_serial_set_baud (self , baud = 115200 ):
444+ """Set 485 baud rate, default 115200
445+
446+ Args:
447+ baud (int): baud rate
448+ """
449+ return self ._mesg (ProtocolCode .TOOL_SERIAL_SET_BAUD , baud )
450+
451+ def tool_serial_set_timeout (self , max_time ):
452+ """Set 485 timeout in milliseconds, default 30ms
453+
454+ Args:
455+ max_time (int): timeout
456+ """
457+ self .calibration_parameters (class_name = self .__class__ .__name__ , max_time = max_time )
458+ return self ._mesg (ProtocolCode .TOOL_SERIAL_SET_TIME_OUT , max_time )
459+
460+ def get_robot_status (self ):
461+ return self ._mesg (ProtocolCode .MERCURY_ROBOT_STATUS , has_reply = True )
358462
359463
0 commit comments