Skip to content

Commit 3f2d527

Browse files
committed
add new interface
1 parent 09847e0 commit 3f2d527

File tree

12 files changed

+46
-22
lines changed

12 files changed

+46
-22
lines changed

pymycobot/cobotx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def _mesg(self, genre, *args, **kwargs):
9595
return res
9696
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES]:
9797
return [self._int2coord(angle) for angle in res]
98+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
99+
return self._int2coord(self._process_single(res))
98100
elif genre in [
99101
ProtocolCode.GET_JOINT_MAX_ANGLE,
100102
ProtocolCode.GET_JOINT_MIN_ANGLE,

pymycobot/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ProtocolCode(object):
1818

1919
GET_ERROR_INFO = 0x07
2020
CLEAR_ERROR_INFO = 0x08
21+
GET_ATOM_VERSION = 0x09
2122

2223
# Overall status
2324
POWER_ON = 0x10
@@ -132,6 +133,7 @@ class ProtocolCode(object):
132133
GET_TOF_DISTANCE = 0xC0
133134
GET_BASIC_VERSION = 0xC1
134135
SET_COMMUNICATE_MODE = 0xC2
136+
GET_COMMUNICATE_MODE = 0xC3
135137

136138
# Coordinate transformation
137139
SET_TOOL_REFERENCE = 0x81

pymycobot/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def public_check(parameter_list, kwargs, robot_limit, class_name, exception_clas
104104
check_0_or_1(parameter, value, [0, 1], value_type, exception_class, int)
105105
elif parameter == 'speed':
106106
check_value_type(parameter, value_type, exception_class, int)
107-
if not 1 <= value <= 100:
107+
if not 1 <= value <= 100:
108108
raise exception_class(
109109
"speed value not right, should be 1 ~ 100, the received speed is %s"
110110
% value

pymycobot/generate.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,5 +1080,17 @@ def set_communicate_mode(self, mode):
10801080
self.calibration_parameters(class_name = self.__class__.__name__, mode=mode)
10811081
return self._mesg(ProtocolCode.SET_COMMUNICATE_MODE, mode)
10821082

1083+
def get_communicate_mode(self):
1084+
self._mesg(ProtocolCode.GET_COMMUNICATE_MODE, has_reply = True)
1085+
10831086
def get_angles_coords(self):
1084-
return self._mesg(ProtocolCode.GET_ANGLES_COORDS, has_reply = True)
1087+
"""Get basic communication mode"""
1088+
return self._mesg(ProtocolCode.GET_ANGLES_COORDS, has_reply = True)
1089+
1090+
def get_atom_version(self):
1091+
"""Get atom firmware version.
1092+
1093+
Returns:
1094+
float: version number.
1095+
"""
1096+
return self._mesg(ProtocolCode.GET_ATOM_VERSION, has_reply = True)

pymycobot/mecharmsocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def _mesg(self, genre, *args, **kwargs):
129129
return [self._int2coord(angle) for angle in res]
130130
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
131131
return self._int2coord(res[0])
132-
elif genre in [ProtocolCode.SOFTWARE_VERSION]:
132+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
133133
return self._int2coord(self._process_single(res))
134134
elif genre == ProtocolCode.GET_ANGLES_COORDS:
135135
r = []

pymycobot/myarm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def _mesg(self, genre, *args, **kwargs):
129129
return [self._int2coord(angle) for angle in res]
130130
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
131131
return self._int2coord(res[0])
132+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
133+
return self._int2coord(self._process_single(res))
132134
elif genre == ProtocolCode.GET_ANGLES_COORDS:
133135
r = []
134136
for index in range(len(res)):

pymycobot/myarmsocket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def _mesg(self, genre, *args, **kwargs):
129129
return [self._int2coord(angle) for angle in res]
130130
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
131131
return self._int2coord(res[0])
132+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
133+
return self._int2coord(self._process_single(res))
132134
elif genre == ProtocolCode.GET_ANGLES_COORDS:
133135
r = []
134136
for index in range(len(res)):

pymycobot/mycobot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _mesg(self, genre, *args, **kwargs):
130130
return [self._int2coord(angle) for angle in res]
131131
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
132132
return self._int2coord(res[0])
133-
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION]:
133+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
134134
return self._int2coord(self._process_single(res))
135135
elif genre == ProtocolCode.GET_ANGLES_COORDS:
136136
r = []

pymycobot/mycobotsocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _mesg(self, genre, *args, **kwargs):
130130
return [self._int2coord(angle) for angle in res]
131131
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
132132
return self._int2coord(res[0])
133-
elif genre in [ProtocolCode.SOFTWARE_VERSION]:
133+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
134134
return self._int2coord(self._process_single(res))
135135
elif genre == ProtocolCode.GET_ANGLES_COORDS:
136136
r = []

pymycobot/mypalletizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _mesg(self, genre, *args, **kwargs):
163163
ProtocolCode.GET_JOINT_MAX_ANGLE,
164164
]:
165165
return self._int2angle(res[0]) if res else 0
166-
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION]:
166+
elif genre in [ProtocolCode.GET_BASIC_VERSION, ProtocolCode.SOFTWARE_VERSION, ProtocolCode.GET_ATOM_VERSION]:
167167
return self._int2coord(self._process_single(res))
168168
elif genre == ProtocolCode.GET_ANGLES_COORDS:
169169
r = []

0 commit comments

Comments
 (0)