pymycobot 3.5.0.dev2__tar.gz → 3.5.0.dev4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {pymycobot-3.5.0.dev2/pymycobot.egg-info → pymycobot-3.5.0.dev4}/PKG-INFO +1 -1
  2. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/__init__.py +1 -1
  3. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/error.py +212 -157
  4. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mercury_api.py +10 -9
  5. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4/pymycobot.egg-info}/PKG-INFO +1 -1
  6. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/LICENSE +0 -0
  7. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/MANIFEST.in +0 -0
  8. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/README.md +0 -0
  9. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/Interface.py +0 -0
  10. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/bluet.py +0 -0
  11. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/common.py +0 -0
  12. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/elephantrobot.py +0 -0
  13. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/generate.py +0 -0
  14. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/genre.py +0 -0
  15. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/log.py +0 -0
  16. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mecharm.py +0 -0
  17. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mecharmsocket.py +0 -0
  18. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mercury.py +0 -0
  19. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mercurychassis.py +0 -0
  20. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mercurysocket.py +0 -0
  21. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myagv.py +0 -0
  22. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myarm.py +0 -0
  23. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myarm_api.py +0 -0
  24. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myarmc.py +0 -0
  25. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myarmm.py +0 -0
  26. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/myarmsocket.py +0 -0
  27. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mybuddy.py +0 -0
  28. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mybuddybluetooth.py +0 -0
  29. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mybuddyemoticon.py +0 -0
  30. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mybuddysocket.py +0 -0
  31. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mycobot.py +0 -0
  32. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mycobotpro630.py +0 -0
  33. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mycobotsocket.py +0 -0
  34. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mypalletizer.py +0 -0
  35. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/mypalletizersocket.py +0 -0
  36. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/progripper.py +0 -0
  37. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/public.py +0 -0
  38. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/ultraArm.py +0 -0
  39. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot/utils.py +0 -0
  40. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot.egg-info/SOURCES.txt +0 -0
  41. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot.egg-info/dependency_links.txt +0 -0
  42. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot.egg-info/requires.txt +0 -0
  43. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/pymycobot.egg-info/top_level.txt +0 -0
  44. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/requirements.txt +0 -0
  45. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/setup.cfg +0 -0
  46. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/setup.py +0 -0
  47. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/tests/test_api.py +0 -0
  48. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/tests/test_generator.py +0 -0
  49. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/tests/test_socket.py +0 -0
  50. {pymycobot-3.5.0.dev2 → pymycobot-3.5.0.dev4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymycobot
3
- Version: 3.5.0.dev2
3
+ Version: 3.5.0.dev4
4
4
  Summary: Python API for serial communication of MyCobot.
5
5
  Home-page: https://github.com/elephantrobotics/pymycobot
6
6
  Author: Elephantrobotics
@@ -61,7 +61,7 @@ if sys.platform == "linux":
61
61
  from pymycobot.mybuddyemoticon import MyBuddyEmoticon
62
62
  __all__.append("MyBuddyEmoticon")
63
63
 
64
- __version__ = "3.5.0dev2"
64
+ __version__ = "3.5.0dev4"
65
65
  __author__ = "Elephantrobotics"
66
66
  __email__ = "weiquan.xu@elephantrobotics.com"
67
67
  __git_url__ = "https://github.com/elephantrobotics/pymycobot"
@@ -16,24 +16,31 @@ MAX_ANGLE = 190.0
16
16
  class MyCobotDataException(Exception):
17
17
  pass
18
18
 
19
+
19
20
  class MercuryDataException(Exception):
20
21
  pass
21
22
 
23
+
22
24
  class MyAgvDataException(Exception):
23
25
  pass
24
26
 
27
+
25
28
  class MechArmDataException(Exception):
26
29
  pass
27
30
 
31
+
28
32
  class MyArmDataException(Exception):
29
33
  pass
30
34
 
35
+
31
36
  class UltraArmDataException(Exception):
32
37
  pass
33
38
 
39
+
34
40
  class MyPalletizerDataException(Exception):
35
41
  pass
36
42
 
43
+
37
44
  class MyBuddyDataException(Exception):
38
45
  pass
39
46
 
@@ -41,19 +48,24 @@ class MyBuddyDataException(Exception):
41
48
  def check_boolean(b):
42
49
  if b != 0 and b != 1:
43
50
  raise MyCobotDataException("This parameter needs to be 0 or 1")
44
-
51
+
52
+
45
53
  def check_rgb_value(value, exception_class, class_name):
46
54
  rgb_str = ["r", "g", "b"]
47
55
  for i, v in enumerate(value):
48
56
  if not (0 <= v <= 255):
49
57
  raise exception_class(
50
- "The RGB value for {} needs to be 0 ~ 255, but received the {} is {}".format(class_name, rgb_str[i], v)
58
+ "The RGB value for {} needs to be 0 ~ 255, but received the {} is {}".format(
59
+ class_name, rgb_str[i], v)
51
60
  )
52
61
 
62
+
53
63
  def check_value_type(parameter, value_type, exception_class, _type):
54
64
  if value_type is not _type:
55
- raise exception_class("The acceptable parameter {} should be an {}, but the received {}".format(parameter, _type, value_type))
56
-
65
+ raise exception_class("The acceptable parameter {} should be an {}, but the received {}".format(
66
+ parameter, _type, value_type))
67
+
68
+
57
69
  def check_coords(value, robot_limit, class_name, exception_class):
58
70
  if len(value) != 6:
59
71
  raise exception_class("The length of `coords` must be 6.")
@@ -64,7 +76,8 @@ def check_coords(value, robot_limit, class_name, exception_class):
64
76
  idx, robot_limit[class_name]["coords_min"][idx], robot_limit[class_name]["coords_max"][idx], coord
65
77
  )
66
78
  )
67
-
79
+
80
+
68
81
  def check_0_or_1(parameter, value, range_data, value_type, exception_class, _type):
69
82
  check_value_type(parameter, value_type, exception_class, _type)
70
83
  if value not in range_data:
@@ -76,63 +89,75 @@ def check_0_or_1(parameter, value, range_data, value_type, exception_class, _typ
76
89
  error += " or "
77
90
  error += ", but the received value is {}".format(value)
78
91
  raise exception_class(error)
79
-
92
+
93
+
80
94
  def check_id(value, id_list, exception_class):
81
95
  raise exception_class(
82
96
  "The id not right, should be in {0}, but received {1}.".format(
83
- id_list, value
97
+ id_list, value
84
98
  )
85
99
  )
86
-
100
+
101
+
87
102
  def public_check(parameter_list, kwargs, robot_limit, class_name, exception_class):
88
103
  for parameter in parameter_list[1:]:
89
104
  value = kwargs.get(parameter, None)
90
105
  value_type = type(value)
91
106
  if parameter == 'id' and value not in robot_limit[class_name][parameter]:
92
- check_id(value, robot_limit[class_name][parameter], exception_class)
107
+ check_id(value, robot_limit[class_name]
108
+ [parameter], exception_class)
93
109
  elif parameter == 'rgb':
94
110
  check_rgb_value(value, exception_class, class_name)
95
111
  elif parameter == 'value':
96
112
  check_value_type(parameter, value_type, exception_class, int)
97
113
  if value < 0 or value > 4096:
98
- raise exception_class("The range of {} is 0 ~ 4096, but the received value is {}".format(parameter, value))
114
+ raise exception_class(
115
+ "The range of {} is 0 ~ 4096, but the received value is {}".format(parameter, value))
99
116
  elif parameter == 'pin_mode':
100
117
  check_value_type(parameter, value_type, exception_class, int)
101
- if value not in [0,1,2]:
102
- raise exception_class("The data supported by parameter {} is 0 or 1 or 2, but the received value is {}".format(parameter, value))
118
+ if value not in [0, 1, 2]:
119
+ raise exception_class(
120
+ "The data supported by parameter {} is 0 or 1 or 2, but the received value is {}".format(parameter, value))
103
121
  elif parameter == 'pin_signal':
104
- check_0_or_1(parameter, value, [0, 1], value_type, exception_class, int)
122
+ check_0_or_1(parameter, value, [0, 1],
123
+ value_type, exception_class, int)
105
124
  elif parameter == 'speed':
106
125
  check_value_type(parameter, value_type, exception_class, int)
107
- if not 1 <= value <= 100:
126
+ if not 1 <= value <= 100:
108
127
  raise exception_class(
109
128
  "speed value not right, should be 1 ~ 100, the received speed is %s"
110
129
  % value
111
130
  )
112
131
  elif parameter == 'flag':
113
- check_0_or_1(parameter, value, [0, 1, 254], value_type, exception_class, int)
132
+ check_0_or_1(parameter, value, [
133
+ 0, 1, 254], value_type, exception_class, int)
114
134
  elif parameter == 'gripper_type':
115
- check_0_or_1(parameter, value, [1, 3, 4], value_type, exception_class, int)
135
+ check_0_or_1(parameter, value, [
136
+ 1, 3, 4], value_type, exception_class, int)
116
137
  elif parameter == '_type_1':
117
- check_0_or_1(parameter, value, [1, 2, 3, 4], value_type, exception_class, int)
138
+ check_0_or_1(parameter, value, [
139
+ 1, 2, 3, 4], value_type, exception_class, int)
118
140
  # if value not in [0, 1, 10]:
119
141
  # raise exception_class("The data supported by parameter {} is 0 or 1 or 10, but the received value is {}".format(parameter, value))
120
142
  elif parameter == 'gripper_value':
121
143
  check_value_type(parameter, value_type, exception_class, int)
122
144
  if value < 0 or value > 100:
123
- raise exception_class("The range of {} is 0 ~ 100, but the received value is {}".format(parameter, value))
145
+ raise exception_class(
146
+ "The range of {} is 0 ~ 100, but the received value is {}".format(parameter, value))
124
147
  elif parameter in ['account', 'password']:
125
148
  check_value_type(parameter, value_type, exception_class, str)
126
149
  # TODO 280/320共用MyCobot,无法进行数据限位
127
150
  # elif parameter == 'coords':
128
151
  # check_coords(value, robot_limit, class_name, exception_class)
129
152
  elif parameter in ['rftype', 'move_type', 'end', 'is_linear', 'status', 'mode', 'direction']:
130
- check_0_or_1(parameter, value, [0, 1], value_type, exception_class, int)
153
+ check_0_or_1(parameter, value, [0, 1],
154
+ value_type, exception_class, int)
131
155
  elif parameter == 'acceleration':
132
156
  check_value_type(parameter, value_type, exception_class, int)
133
157
  if not 1 <= value <= 100:
134
158
  raise exception_class(
135
- "{} value not right, should be 1 ~ 100, the received is {}".format(parameter, value)
159
+ "{} value not right, should be 1 ~ 100, the received is {}".format(
160
+ parameter, value)
136
161
  )
137
162
  elif parameter == 'angle':
138
163
  id = kwargs.get('id', None)
@@ -144,24 +169,29 @@ def public_check(parameter_list, kwargs, robot_limit, class_name, exception_clas
144
169
  )
145
170
  )
146
171
  elif parameter == 'encoders':
147
- if "MyCobot" in class_name or "MechArm" in class_name:
172
+ if "MyCobot" in class_name or "MechArm" in class_name:
148
173
  if len(value) != 6:
149
- raise exception_class("The length of `encoders` must be 6.")
174
+ raise exception_class(
175
+ "The length of `encoders` must be 6.")
150
176
  elif "MyPalletizer" in class_name:
151
177
  if len(value) != 4:
152
- raise exception_class("The length of `encoders` must be 4.")
178
+ raise exception_class(
179
+ "The length of `encoders` must be 4.")
153
180
  elif "MyPalletizer" in class_name:
154
181
  if len(value) != 7:
155
- raise exception_class("The length of `encoders` must be 7.")
182
+ raise exception_class(
183
+ "The length of `encoders` must be 7.")
156
184
  for data in value:
157
185
  data_type = type(data)
158
186
  check_value_type(parameter, data_type, exception_class, int)
159
187
  if data < 0 or data > 4096:
160
- raise exception_class("The range of encoder is 0 ~ 4096, but the received value is {}".format(data))
188
+ raise exception_class(
189
+ "The range of encoder is 0 ~ 4096, but the received value is {}".format(data))
161
190
  elif parameter == 'speeds':
162
- if "MyCobot" in class_name or "MechArm" in class_name:
191
+ if "MyCobot" in class_name or "MechArm" in class_name:
163
192
  if len(value) not in [6, 7]:
164
- raise exception_class("The length of `speeds` must be 6. but the received value is {}".format(value))
193
+ raise exception_class(
194
+ "The length of `speeds` must be 6. but the received value is {}".format(value))
165
195
  elif "MyPalletizer" in class_name:
166
196
  if len(value) != 4:
167
197
  raise exception_class("The length of `speeds` must be 4.")
@@ -172,7 +202,8 @@ def public_check(parameter_list, kwargs, robot_limit, class_name, exception_clas
172
202
  data_type = type(data)
173
203
  check_value_type(parameter, data_type, exception_class, int)
174
204
  if data < 0 or data > 3400:
175
- raise exception_class("The range of speed is 0 ~ 3400, but the received value is {}".format(data))
205
+ raise exception_class(
206
+ "The range of speed is 0 ~ 3400, but the received value is {}".format(data))
176
207
  elif parameter in ['servo_id_pdi', 'encode_id']:
177
208
  check_value_type(parameter, value_type, exception_class, int)
178
209
  # if "MyCobot" in class_name or "MechArm" in class_name:
@@ -180,135 +211,142 @@ def public_check(parameter_list, kwargs, robot_limit, class_name, exception_clas
180
211
  # raise exception_class("The range of id is 1 ~ 6, but the received is {}".format(value))
181
212
  if "MyPalletizer" in class_name:
182
213
  if value < 1 or value > 4:
183
- raise exception_class("The range of id is 1 ~ 4, but the received is {}".format(value))
214
+ raise exception_class(
215
+ "The range of id is 1 ~ 4, but the received is {}".format(value))
184
216
  elif "MyArm" in class_name or "MyCobot" in class_name or "MechArm" in class_name:
185
217
  if value < 1 or value > 7:
186
- raise exception_class("The range of id is 1 ~ 7, but the received is {}".format(value))
218
+ raise exception_class(
219
+ "The range of id is 1 ~ 7, but the received is {}".format(value))
187
220
  elif parameter == "torque":
188
221
  torque_min = 150
189
222
  torque_max = 980
190
223
  if value < torque_min or value > torque_max:
191
- raise exception_class("The range of torque is {} ~ {}, but the received is {}".format(torque_min, torque_max, value))
224
+ raise exception_class("The range of torque is {} ~ {}, but the received is {}".format(
225
+ torque_min, torque_max, value))
192
226
  elif parameter == "current":
193
227
  current_min = 1
194
228
  current_max = 500
195
229
  if value < current_min or value > current_max:
196
- raise exception_class("The range of current is {} ~ {}, but the received is {}".format(current_min, current_max, value))
230
+ raise exception_class("The range of current is {} ~ {}, but the received is {}".format(
231
+ current_min, current_max, value))
197
232
  elif parameter == 'end_direction':
198
- check_0_or_1(parameter, value, [1, 2, 3], value_type, exception_class, int)
233
+ check_0_or_1(parameter, value, [
234
+ 1, 2, 3], value_type, exception_class, int)
235
+
199
236
 
200
237
  def calibration_parameters(**kwargs):
201
238
  robot_limit = {
202
- "Mercury":{
203
- "id":[1,2,3,4,5,6,11,12,13],
204
- "angles_min":[-178, -74, -180, -178, -20, -180, -60, -140, -120],
205
- "angles_max":[178, 130, 178, 10, 178, 273, 180, 0, 190, 120],
206
- "coords_min":[-441.37, -441.37, -206.52, -180, -180, -180],
207
- "coords_max":[441.37, 441.37, 628.02, 180, 180, 180]
208
- },
209
- "MercurySocket":{
210
- "id":[1,2,3,4,5,6,11,12,13],
211
- "angles_min":[-178, -74, -180, -178, -20, -180, -60, -140, -120],
212
- "angles_max":[178, 130, 178, 10, 178, 273, 180, 0, 190, 120],
213
- "coords_min":[-466, -466, -240, -180, -180, -180],
214
- "coords_max":[466, 466, 531, 180, 180, 180]
215
- },
216
- "MyCobot":{
217
- "id":[1,2,3,4,5,6, 7],
218
- "angles_min":[-168, -135, -150, -145, -165, -180],
219
- "angles_max":[168, 135, 150, 145, 165, 180],
220
- "coords_min":[-350, -350, -70, -180, -180, -180],
221
- "coords_max":[350, 350, 523.9, 180, 180, 180]
222
- },
223
- "MyCobotSocket":{
224
- "id":[1,2,3,4,5,6, 7],
225
- "angles_min":[-168, -135, -150, -145, -165, -180],
226
- "angles_max":[168, 135, 150, 145, 165, 180],
227
- "coords_min":[-350, -350, -70, -180, -180, -180],
228
- "coords_max":[350, 350, 523.9, 180, 180, 180]
229
- },
230
- "MechArm":{
231
- "id":[1,2,3,4,5,6, 7],
232
- "angles_min":[-165, -90, -180, -165, -115, -175],
233
- "angles_max":[165, 90, 70, 165, 115, 175],
234
- "coords_min":[-272, -272, -36, -180, -180, -180],
235
- "coords_max":[272, 272, 408.9, 180, 180, 180]
236
- },
237
- "MechArmSocket":{
238
- "id":[1,2,3,4,5,6, 7],
239
- "angles_min":[-165, -90, -180, -165, -115, -175],
240
- "angles_max":[165, 90, 70, 165, 115, 175],
241
- "coords_min":[-272, -272, -36, -180, -180, -180],
242
- "coords_max":[272, 272, 408.9, 180, 180, 180]
243
- },
244
- "MyArm":{
245
- "id":[1,2,3,4,5,6,7,8],
246
- "angles_min":[-160, -70, -170, -113, -170, -115, -180],
247
- "angles_max":[160, 115, 170, 75, 170, 115, 180],
248
- "coords_min":[-310, -310, -140, -180, -180, -180],
249
- "coords_max":[310, 310, 480, 180, 180, 180]
250
- },
251
- "MyArmSocket":{
252
- "id":[1,2,3,4,5,6,7,8],
253
- "angles_min":[-160, -70, -170, -113, -170, -115, -180],
254
- "angles_max":[160, 115, 170, 75, 170, 115, 180],
255
- "coords_min":[-310, -310, -140, -180, -180, -180],
256
- "coords_max":[310, 310, 480, 180, 180, 180]
257
- },
258
- "MyPalletizer":{
259
- "id":[1,2,3,4, 7],
260
- "angles_min":[-162, -2, -92, -180],
261
- "angles_max":[162, 90, 60, 180],
262
- "coords_min":[-260, -260, -15, -180],
263
- "coords_max":[260, 260, 357.58, 180]
264
- },
265
- "MyPalletizerSocket":{
266
- "id":[1,2,3,4, 7],
267
- "angles_min":[-162, -2, -92, -180],
268
- "angles_max":[162, 90, 60, 180],
269
- "coords_min":[-260, -260, -15, -180],
270
- "coords_max":[260, 260, 357.58, 180]
271
- },
272
- "UltraArm":{
273
- "id":[1,2,3,4, 7],
274
- "angles_min":[-150, -20, -5, -180],
275
- "angles_max":[170, 90, 110, 180],
276
- "coords_min":[-340, -340, 0, -180],
277
- "coords_max":[340, 340, 270.58, 180]
278
- },
279
- "MyBuddy":{
280
- "id":[1,2,3,4,5,6, 7],
281
- "angles_min":[-165, -165, -165, -165, -165, -175],
282
- "angles_max":[165, 165, 165, 165, 165, 175],
283
- "waist_angle_min":-120,
284
- "waist_angle_max":120,
285
- "left_coords_min":[0, -40, 0, -180,-180,-180],
286
- "left_coords_max":[250, 260, 480, 180,180,180],
287
- "right_coords_min":[0, -260, 0, -180,-180,-180],
288
- "right_coords_max":[250, 40, 480, 180,180,180]
289
- },
290
- "MyBuddySocket":{
291
- "id":[1,2,3,4,5,6, 7],
292
- "angles_min":[-165, -165, -165, -165, -165, -175],
293
- "angles_max":[165, 165, 165, 165, 165, 175],
294
- "waist_angle_min":-120,
295
- "waist_angle_max":120,
296
- "left_coords_min":[0, -40, 0, -180,-180,-180],
297
- "left_coords_max":[250, 260, 480, 180,180,180],
298
- "right_coords_min":[0, -260, 0, -180,-180,-180],
299
- "right_coords_max":[250, 40, 480, 180,180,180]
239
+ "Mercury": {
240
+ "id": [1, 2, 3, 4, 5, 6, 11, 12, 13],
241
+ "angles_min": [-165, -55, -180, -165, -20, -180, -60, -140, -120],
242
+ "angles_max": [165, 95, 5, 165, 273, 180, 0, 190, 120],
243
+ "coords_min": [-441.37, -441.37, -206.52, -180, -180, -180],
244
+ "coords_max": [441.37, 441.37, 628.02, 180, 180, 180]
245
+ },
246
+ "MercurySocket": {
247
+ "id": [1, 2, 3, 4, 5, 6, 11, 12, 13],
248
+ "angles_min": [-165, -55, -180, -165, -20, -180, -60, -140, -120],
249
+ "angles_max": [165, 95, 5, 165, 273, 180, 0, 190, 120],
250
+ "coords_min": [-441.37, -441.37, -206.52, -180, -180, -180],
251
+ "coords_max": [441.37, 441.37, 628.02, 180, 180, 180]
252
+ },
253
+ "MyCobot": {
254
+ "id": [1, 2, 3, 4, 5, 6, 7],
255
+ "angles_min": [-168, -135, -150, -145, -165, -180],
256
+ "angles_max": [168, 135, 150, 145, 165, 180],
257
+ "coords_min": [-350, -350, -70, -180, -180, -180],
258
+ "coords_max": [350, 350, 523.9, 180, 180, 180]
259
+ },
260
+ "MyCobotSocket": {
261
+ "id": [1, 2, 3, 4, 5, 6, 7],
262
+ "angles_min": [-168, -135, -150, -145, -165, -180],
263
+ "angles_max": [168, 135, 150, 145, 165, 180],
264
+ "coords_min": [-350, -350, -70, -180, -180, -180],
265
+ "coords_max": [350, 350, 523.9, 180, 180, 180]
266
+ },
267
+ "MechArm": {
268
+ "id": [1, 2, 3, 4, 5, 6, 7],
269
+ "angles_min": [-165, -90, -180, -165, -115, -175],
270
+ "angles_max": [165, 90, 70, 165, 115, 175],
271
+ "coords_min": [-272, -272, -36, -180, -180, -180],
272
+ "coords_max": [272, 272, 408.9, 180, 180, 180]
273
+ },
274
+ "MechArmSocket": {
275
+ "id": [1, 2, 3, 4, 5, 6, 7],
276
+ "angles_min": [-165, -90, -180, -165, -115, -175],
277
+ "angles_max": [165, 90, 70, 165, 115, 175],
278
+ "coords_min": [-272, -272, -36, -180, -180, -180],
279
+ "coords_max": [272, 272, 408.9, 180, 180, 180]
280
+ },
281
+ "MyArm": {
282
+ "id": [1, 2, 3, 4, 5, 6, 7, 8],
283
+ "angles_min": [-160, -70, -170, -113, -170, -115, -180],
284
+ "angles_max": [160, 115, 170, 75, 170, 115, 180],
285
+ "coords_min": [-310, -310, -140, -180, -180, -180],
286
+ "coords_max": [310, 310, 480, 180, 180, 180]
287
+ },
288
+ "MyArmSocket": {
289
+ "id": [1, 2, 3, 4, 5, 6, 7, 8],
290
+ "angles_min": [-160, -70, -170, -113, -170, -115, -180],
291
+ "angles_max": [160, 115, 170, 75, 170, 115, 180],
292
+ "coords_min": [-310, -310, -140, -180, -180, -180],
293
+ "coords_max": [310, 310, 480, 180, 180, 180]
294
+ },
295
+ "MyPalletizer": {
296
+ "id": [1, 2, 3, 4, 7],
297
+ "angles_min": [-162, -2, -92, -180],
298
+ "angles_max": [162, 90, 60, 180],
299
+ "coords_min": [-260, -260, -15, -180],
300
+ "coords_max": [260, 260, 357.58, 180]
301
+ },
302
+ "MyPalletizerSocket": {
303
+ "id": [1, 2, 3, 4, 7],
304
+ "angles_min": [-162, -2, -92, -180],
305
+ "angles_max": [162, 90, 60, 180],
306
+ "coords_min": [-260, -260, -15, -180],
307
+ "coords_max": [260, 260, 357.58, 180]
308
+ },
309
+ "UltraArm": {
310
+ "id": [1, 2, 3, 4, 7],
311
+ "angles_min": [-150, -20, -5, -180],
312
+ "angles_max": [170, 90, 110, 180],
313
+ "coords_min": [-340, -340, 0, -180],
314
+ "coords_max": [340, 340, 270.58, 180]
315
+ },
316
+ "MyBuddy": {
317
+ "id": [1, 2, 3, 4, 5, 6, 7],
318
+ "angles_min": [-165, -165, -165, -165, -165, -175],
319
+ "angles_max": [165, 165, 165, 165, 165, 175],
320
+ "waist_angle_min": -120,
321
+ "waist_angle_max": 120,
322
+ "left_coords_min": [0, -40, 0, -180, -180, -180],
323
+ "left_coords_max": [250, 260, 480, 180, 180, 180],
324
+ "right_coords_min": [0, -260, 0, -180, -180, -180],
325
+ "right_coords_max": [250, 40, 480, 180, 180, 180]
326
+ },
327
+ "MyBuddySocket": {
328
+ "id": [1, 2, 3, 4, 5, 6, 7],
329
+ "angles_min": [-165, -165, -165, -165, -165, -175],
330
+ "angles_max": [165, 165, 165, 165, 165, 175],
331
+ "waist_angle_min": -120,
332
+ "waist_angle_max": 120,
333
+ "left_coords_min": [0, -40, 0, -180, -180, -180],
334
+ "left_coords_max": [250, 260, 480, 180, 180, 180],
335
+ "right_coords_min": [0, -260, 0, -180, -180, -180],
336
+ "right_coords_max": [250, 40, 480, 180, 180, 180]
337
+ }
300
338
  }
301
- }
302
339
  parameter_list = list(kwargs.keys())
303
- class_name = kwargs.get("class_name", None)
340
+ class_name = kwargs.get("class_name", None)
304
341
  if class_name in ["Mercury", "MercurySocket"]:
305
342
  for parameter in parameter_list[1:]:
306
343
  value = kwargs.get(parameter, None)
307
344
  if parameter == 'id' and value not in robot_limit[class_name][parameter]:
308
- check_id(value, robot_limit[class_name][parameter], MercuryDataException)
345
+ check_id(value, robot_limit[class_name]
346
+ [parameter], MercuryDataException)
309
347
  elif parameter == 'angle':
310
348
  id = kwargs.get('id', None)
311
- if id in [11,12,13]:
349
+ if id in [11, 12, 13]:
312
350
  index = robot_limit[class_name]['id'][id-4] - 4
313
351
  else:
314
352
  index = robot_limit[class_name]['id'][id-1] - 1
@@ -330,7 +368,7 @@ def calibration_parameters(**kwargs):
330
368
  # )
331
369
 
332
370
  elif parameter == 'coord':
333
-
371
+
334
372
  index = kwargs.get('id', None) - 1
335
373
  if value < robot_limit[class_name]["coords_min"][index] or value > robot_limit[class_name]["coords_max"][index]:
336
374
  raise MercuryDataException(
@@ -339,7 +377,8 @@ def calibration_parameters(**kwargs):
339
377
  )
340
378
  )
341
379
  elif parameter == 'coords':
342
- check_coords(value, robot_limit, class_name, MercuryDataException)
380
+ check_coords(value, robot_limit, class_name,
381
+ MercuryDataException)
343
382
 
344
383
  elif parameter == 'speed' and not 1 <= value <= 100:
345
384
  raise MercuryDataException(
@@ -352,30 +391,38 @@ def calibration_parameters(**kwargs):
352
391
  # if direction is not None:
353
392
  elif parameter in ['direction', 'flag', 'value']:
354
393
  if value not in [0, 1]:
355
- raise MercuryDataException("{} only supports 0 or 1, but received {}".format(parameter, value))
356
-
394
+ raise MercuryDataException(
395
+ "{} only supports 0 or 1, but received {}".format(parameter, value))
396
+
357
397
  elif parameter == 'coord_id':
358
398
  if value < 1 or value > 6:
359
- raise MercuryDataException("coord_id only supports 1 ~ 6, but received {}".format(value))
360
-
399
+ raise MercuryDataException(
400
+ "coord_id only supports 1 ~ 6, but received {}".format(value))
401
+
361
402
  elif parameter == 'solution_angle':
362
403
  if value > 90 or value < -90:
363
- raise MercuryDataException("The angle range is -90° ~ 90°, but received {}".format(value))
404
+ raise MercuryDataException(
405
+ "The angle range is -90° ~ 90°, but received {}".format(value))
364
406
  elif parameter == 'address':
365
407
  if value < 32 or value > 34:
366
- raise MercuryDataException("The angle address is 32 ~ 34, but received {}".format(value))
408
+ raise MercuryDataException(
409
+ "The angle address is 32 ~ 34, but received {}".format(value))
367
410
  elif parameter == 'value':
368
411
  if value < 1 or value > 32000:
369
- raise MercuryDataException("The angle value is 1 ~ 32000, but received {}".format(value))
412
+ raise MercuryDataException(
413
+ "The angle value is 1 ~ 32000, but received {}".format(value))
370
414
  elif parameter == "servo_restore":
371
- if value not in [1,2,3,4,5,6,7,13,254]:
372
- raise MercuryDataException("The joint_id should be in [1,2,3,4,5,6,7,13,254], but received {}".format(value))
415
+ if value not in [1, 2, 3, 4, 5, 6, 7, 13, 254]:
416
+ raise MercuryDataException(
417
+ "The joint_id should be in [1,2,3,4,5,6,7,13,254], but received {}".format(value))
373
418
  elif parameter == "data_len":
374
419
  if value < 1 or value > 45:
375
- raise MercuryDataException("The parameter data_len data range only supports 1 ~ 45, but received {}".format(value))
420
+ raise MercuryDataException(
421
+ "The parameter data_len data range only supports 1 ~ 45, but received {}".format(value))
376
422
  elif parameter == "max_time":
377
423
  if value < 0:
378
- raise MercuryDataException("The parameter max_time must be greater than or equal to 0, but received {}".format(value))
424
+ raise MercuryDataException(
425
+ "The parameter max_time must be greater than or equal to 0, but received {}".format(value))
379
426
  elif class_name == "MyAgv":
380
427
  for parameter in parameter_list[1:]:
381
428
  value = kwargs.get(parameter, None)
@@ -383,23 +430,31 @@ def calibration_parameters(**kwargs):
383
430
  check_rgb_value(value, MyAgvDataException, class_name)
384
431
  elif parameter == 'led_mode':
385
432
  if value not in [1, 2]:
386
- raise MyAgvDataException("led mode only supports 1 or 2, but received is {}".format(value))
433
+ raise MyAgvDataException(
434
+ "led mode only supports 1 or 2, but received is {}".format(value))
387
435
  elif parameter == 'direction_1':
388
436
  if value < 0 or value > 255:
389
- raise MyAgvDataException("The range of direction_1 is 0 ~ 255, but the received value is {}".format(value))
437
+ raise MyAgvDataException(
438
+ "The range of direction_1 is 0 ~ 255, but the received value is {}".format(value))
390
439
  elif parameter == 'direction_2':
391
440
  if value < 0 or value > 255:
392
- raise MyAgvDataException("The range of direction_2 is 0 ~ 255, but the received value is {}".format(value))
441
+ raise MyAgvDataException(
442
+ "The range of direction_2 is 0 ~ 255, but the received value is {}".format(value))
393
443
  elif parameter == 'direction_3':
394
444
  if value < 0 or value > 255:
395
- raise MyAgvDataException("The range of direction_3 is 0 ~ 255, but the received value is {}".format(value))
445
+ raise MyAgvDataException(
446
+ "The range of direction_3 is 0 ~ 255, but the received value is {}".format(value))
396
447
  elif parameter == 'data':
397
448
  if value < 1 or value > 127:
398
- raise MyAgvDataException("The range of {} is 1 ~ 127, but the received value is {}".format(parameter, value))
399
-
449
+ raise MyAgvDataException(
450
+ "The range of {} is 1 ~ 127, but the received value is {}".format(parameter, value))
451
+
400
452
  elif class_name in ["MyCobot", "MyCobotSocket"]:
401
- public_check(parameter_list, kwargs, robot_limit, class_name, MyCobotDataException)
453
+ public_check(parameter_list, kwargs, robot_limit,
454
+ class_name, MyCobotDataException)
402
455
  elif class_name in ["MechArm", "MechArmSocket"]:
403
- public_check(parameter_list, kwargs, robot_limit, class_name, MechArmDataException)
456
+ public_check(parameter_list, kwargs, robot_limit,
457
+ class_name, MechArmDataException)
404
458
  elif class_name in ["MyArm", "MyArmSocket"]:
405
- public_check(parameter_list, kwargs, robot_limit, class_name, MyArmDataException)
459
+ public_check(parameter_list, kwargs, robot_limit,
460
+ class_name, MyArmDataException)
@@ -121,7 +121,7 @@ class MercuryCommandGenerator(CommandGenerator):
121
121
  byte_value = int.from_bytes(valid_data[i:i+4], byteorder='big', signed=True)
122
122
  i+=4
123
123
  res.append(byte_value)
124
- elif data_len == 6 and genre in [ProtocolCode.GET_SERVO_STATUS, ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.GET_SERVO_CURRENTS]:
124
+ elif data_len == 6 and genre in [ProtocolCode.GET_SERVO_STATUS, ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.GET_SERVO_CURRENTS, ProtocolCode.GET_MODEL_DIRECTION]:
125
125
  for i in range(data_len):
126
126
  res.append(valid_data[i])
127
127
  elif data_len == 24:
@@ -870,7 +870,7 @@ class MercuryCommandGenerator(CommandGenerator):
870
870
  """
871
871
  return self._mesg(ProtocolCode.MERCURY_GET_POS_OVER_SHOOT, has_reply=True)
872
872
 
873
- def stop(self, deceleration=False):
873
+ def stop(self, deceleration=0):
874
874
  """Robot stops moving
875
875
 
876
876
  Args:
@@ -879,12 +879,12 @@ class MercuryCommandGenerator(CommandGenerator):
879
879
  Returns:
880
880
  int: 1 - Stop completion
881
881
  """
882
- if deceleration:
883
- return self._mesg(ProtocolCode.STOP, has_reply=True)
884
- else:
882
+ if deceleration == 1:
885
883
  return self._mesg(ProtocolCode.STOP, 1, has_reply=True)
884
+ else:
885
+ return self._mesg(ProtocolCode.STOP, has_reply=True)
886
886
 
887
- def pause(self, deceleration=False):
887
+ def pause(self, deceleration=0):
888
888
  """Robot pauses movement
889
889
 
890
890
  Args:
@@ -893,10 +893,11 @@ class MercuryCommandGenerator(CommandGenerator):
893
893
  Returns:
894
894
  int: 1 - pause completion
895
895
  """
896
- if deceleration:
897
- return self._mesg(ProtocolCode.PAUSE, has_reply=True)
898
- else:
896
+ if deceleration == 1:
899
897
  return self._mesg(ProtocolCode.PAUSE, 1, has_reply=True)
898
+ else:
899
+ return self._mesg(ProtocolCode.PAUSE, has_reply=True)
900
+
900
901
 
901
902
  def get_modified_version(self):
902
903
  return self._mesg(ProtocolCode.ROBOT_VERSION, has_reply=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymycobot
3
- Version: 3.5.0.dev2
3
+ Version: 3.5.0.dev4
4
4
  Summary: Python API for serial communication of MyCobot.
5
5
  Home-page: https://github.com/elephantrobotics/pymycobot
6
6
  Author: Elephantrobotics
File without changes
File without changes
File without changes
File without changes