Skip to content

Commit 3009e4d

Browse files
committed
add 320 interface: set_gripper_mode(mode), get_gripper_mode(), get_servo_last_pdi(id)
1 parent 1b954bd commit 3009e4d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

pymycobot/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class ProtocolCode(object):
9292
SET_COLOR = 0x6A
9393
SET_ELETRIC_GRIPPER = 0x6B
9494
INIT_ELETRIC_GRIPPER = 0x6C
95+
SET_GRIPPER_MODE = 0x6D
96+
GET_GRIPPER_MODE = 0x6E
9597

9698
GET_ACCEI_DATA = 0x73
9799

@@ -144,6 +146,7 @@ class ProtocolCode(object):
144146
GET_SERVO_VOLTAGES = 0xE3
145147
GET_SERVO_STATUS = 0xE4
146148
GET_SERVO_TEMPS = 0xE5
149+
GET_SERVO_LASTPDI = 0xE6
147150

148151
GET_BASE_COORDS = 0xF0
149152
BASE_TO_SINGLE_COORDS = 0xF1
@@ -302,6 +305,9 @@ def _process_received(self, data, genre, arm=6):
302305
res.append(self._decode_int16(valid_data))
303306
elif data_len == 3:
304307
res.append(self._decode_int16(valid_data[1:]))
308+
elif data_len == 4:
309+
for i in range(1,4):
310+
res.append(valid_data[i])
305311
elif data_len == 7:
306312
error_list = [i for i in valid_data]
307313
for i in error_list:

pymycobot/generate.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,3 +962,29 @@ def set_fresh_mode(self, mode): # TODO 22-5-19 need test
962962
def get_fresh_mode(self):
963963
"""Query sports mode"""
964964
return self._mesg(ProtocolCode.GET_FRESH_MODE, has_reply = True)
965+
966+
def set_gripper_mode(self, mode):
967+
"""Set gripper mode
968+
969+
Args:
970+
mode: 0 - transparent transmission. 1 - Port Mode.
971+
972+
"""
973+
return self._mesg(ProtocolCode.SET_GRIPPER_MODE, mode)
974+
975+
def get_gripper_mode(self):
976+
"""Get gripper mode
977+
978+
Return:
979+
mode: 0 - transparent transmission. 1 - Port Mode.
980+
"""
981+
return self._mesg(ProtocolCode.GET_GRIPPER_MODE, has_reply = True)
982+
983+
def get_servo_last_pdi(self, id):
984+
"""Obtain the pdi of a single steering gear before modification
985+
986+
Args:
987+
id: 1 - 6.0
988+
"""
989+
return self._mesg(ProtocolCode.GET_SERVO_LASTPDI, id, has_reply = True)
990+

pymycobot/mycobot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def _mesg(self, genre, *args, **kwargs):
110110
ProtocolCode.GET_REFERENCE_FRAME,
111111
ProtocolCode.GET_JOINT_MIN_ANGLE,
112112
ProtocolCode.GET_JOINT_MAX_ANGLE,
113-
ProtocolCode.GET_FRESH_MODE
113+
ProtocolCode.GET_FRESH_MODE,
114+
ProtocolCode.GET_GRIPPER_MODE
114115
]:
115116
return self._process_single(res)
116117
elif genre in [ProtocolCode.GET_ANGLES]:

0 commit comments

Comments
 (0)