Skip to content

Commit aead163

Browse files
committed
fix bug
1 parent 593e9a2 commit aead163

File tree

5 files changed

+56
-20
lines changed

5 files changed

+56
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# ChangeLog for pymycobot
22

3+
## v3.3.6 (2024-1-12)
4+
5+
- release v3.3.6
6+
- fix bug
7+
38
## v3.3.5 (2023-12-29)
49

510
- release v3.3.5

pymycobot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from pymycobot.mybuddyemoticon import MyBuddyEmoticon
5555
__all__.append("MyBuddyEmoticon")
5656

57-
__version__ = "3.3.5"
57+
__version__ = "3.3.6"
5858
__author__ = "Elephantrobotics"
5959
__email__ = "weiquan.xu@elephantrobotics.com"
6060
__git_url__ = "https://github.com/elephantrobotics/pymycobot"

pymycobot/mybuddy.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,9 @@ def _read(self):
106106
datas = b'\xfe'
107107
pre = k
108108
except:
109-
self.log.debug("_read: {}".format(datas))
110-
111-
datas = None
112109
break
113110
else:
114-
self.log.debug("_read: {}".format(datas))
115-
116-
datas = None
111+
datas = b''
117112
self.log.debug("_read: {}".format(datas))
118113
return datas
119114

pymycobot/mybuddybluetooth.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,45 @@ def _mesg(self, genre, *args, **kwargs):
7878
ProtocolCode.GET_END_TYPE,
7979
ProtocolCode.GET_MOVEMENT_TYPE,
8080
ProtocolCode.GET_REFERENCE_FRAME,
81-
ProtocolCode.GET_JOINT_MIN_ANGLE,
82-
ProtocolCode.GET_JOINT_MAX_ANGLE
81+
ProtocolCode.GET_FRESH_MODE,
82+
ProtocolCode.SetHTSGripperTorque,
83+
ProtocolCode.GetHTSGripperTorque,
84+
ProtocolCode.GetGripperProtectCurrent,
85+
ProtocolCode.InitGripper,
86+
ProtocolCode.SET_FOUR_PIECES_ZERO
87+
# ProtocolCode.GET_SERVO_CURRENTS
8388
]:
8489
return self._process_single(res)
8590
elif genre in [ProtocolCode.GET_ANGLES]:
8691
return [self._int2angle(angle) for angle in res]
8792
elif genre in [ProtocolCode.GET_ANGLE]:
88-
return self._process_single(self._int2angle(angle) for angle in res)
93+
return self._int2angle(res[0]) if res else None
8994
elif genre in [ProtocolCode.GET_COORD]:
9095
if real_command[5] < 4:
91-
return self._int2coord(res[0])
96+
if real_command[2] == 3:
97+
return self._int2angle(res[0]) if res else None
98+
return self._int2coord(res[0]) if res else None
9299
else:
93-
return self._int2angle(res[0])
94-
elif genre in [ProtocolCode.GET_COORDS, ProtocolCode.GET_TOOL_REFERENCE, ProtocolCode.GET_WORLD_REFERENCE, ProtocolCode.GET_BASE_COORDS, ProtocolCode.BASE_TO_SINGLE_COORDS]:
100+
return self._int2angle(res[0]) if res else None
101+
elif genre in [ProtocolCode.GET_ALL_BASE_COORDS, ProtocolCode.GET_COORDS, ProtocolCode.GET_TOOL_REFERENCE, ProtocolCode.GET_WORLD_REFERENCE, ProtocolCode.GET_BASE_COORDS, ProtocolCode.GET_BASE_COORD, ProtocolCode.BASE_TO_SINGLE_COORDS]:
95102
if res:
96-
r = []
103+
r = []
97104
for idx in range(3):
98105
r.append(self._int2coord(res[idx]))
99106
for idx in range(3, 6):
100107
r.append(self._int2angle(res[idx]))
108+
if len(res) == 12:
109+
r1 = []
110+
for idx in range(6, 9):
111+
r1.append(self._int2coord(res[idx]))
112+
for idx in range(9, 12):
113+
r1.append(self._int2angle(res[idx]))
114+
return [r, r1]
101115
return r
102-
else:
116+
else:
103117
return res
118+
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
119+
return self._int2coord(res[0])
104120
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.COLLISION]:
105121
return [self._int2coord(angle) for angle in res]
106122
else:

pymycobot/mybuddysocket.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def _mesg(self, genre, *args, **kwargs):
101101
return None
102102
if genre in [
103103
ProtocolCode.ROBOT_VERSION,
104+
ProtocolCode.SOFTWARE_VERSION,
105+
ProtocolCode.GET_ROBOT_ID,
104106
ProtocolCode.IS_POWER_ON,
105107
ProtocolCode.IS_CONTROLLER_CONNECTED,
106108
ProtocolCode.IS_PAUSED, # TODO have bug: return b''
@@ -119,28 +121,46 @@ def _mesg(self, genre, *args, **kwargs):
119121
ProtocolCode.GET_END_TYPE,
120122
ProtocolCode.GET_MOVEMENT_TYPE,
121123
ProtocolCode.GET_REFERENCE_FRAME,
122-
ProtocolCode.GET_JOINT_MIN_ANGLE,
123-
ProtocolCode.GET_JOINT_MAX_ANGLE,
124+
ProtocolCode.GET_FRESH_MODE,
124125
ProtocolCode.SetHTSGripperTorque,
125126
ProtocolCode.GetHTSGripperTorque,
126127
ProtocolCode.GetGripperProtectCurrent,
127128
ProtocolCode.InitGripper,
128129
ProtocolCode.SET_FOUR_PIECES_ZERO
130+
# ProtocolCode.GET_SERVO_CURRENTS
129131
]:
130132
return self._process_single(res)
131133
elif genre in [ProtocolCode.GET_ANGLES]:
132134
return [self._int2angle(angle) for angle in res]
133-
elif genre in [ProtocolCode.GET_COORDS, ProtocolCode.GET_TOOL_REFERENCE, ProtocolCode.GET_WORLD_REFERENCE]:
135+
elif genre in [ProtocolCode.GET_ANGLE]:
136+
return self._int2angle(res[0]) if res else None
137+
elif genre in [ProtocolCode.GET_COORD]:
138+
if real_command[5] < 4:
139+
if real_command[2] == 3:
140+
return self._int2angle(res[0]) if res else None
141+
return self._int2coord(res[0]) if res else None
142+
else:
143+
return self._int2angle(res[0]) if res else None
144+
elif genre in [ProtocolCode.GET_ALL_BASE_COORDS, ProtocolCode.GET_COORDS, ProtocolCode.GET_TOOL_REFERENCE, ProtocolCode.GET_WORLD_REFERENCE, ProtocolCode.GET_BASE_COORDS, ProtocolCode.GET_BASE_COORD, ProtocolCode.BASE_TO_SINGLE_COORDS]:
134145
if res:
135-
r = []
146+
r = []
136147
for idx in range(3):
137148
r.append(self._int2coord(res[idx]))
138149
for idx in range(3, 6):
139150
r.append(self._int2angle(res[idx]))
151+
if len(res) == 12:
152+
r1 = []
153+
for idx in range(6, 9):
154+
r1.append(self._int2coord(res[idx]))
155+
for idx in range(9, 12):
156+
r1.append(self._int2angle(res[idx]))
157+
return [r, r1]
140158
return r
141159
else:
142160
return res
143-
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES]:
161+
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
162+
return self._int2coord(res[0])
163+
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.COLLISION]:
144164
return [self._int2coord(angle) for angle in res]
145165
else:
146166
return res

0 commit comments

Comments
 (0)