Skip to content

Commit 48bb575

Browse files
committed
Merge branch 'mycobot_280_refactor' of github.com:elephantrobotics/pymycobot into myhand_gripper
2 parents afeb5b2 + 7187cfb commit 48bb575

File tree

2 files changed

+92
-8
lines changed

2 files changed

+92
-8
lines changed

pymycobot/error.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,28 +294,28 @@ def calibration_parameters(**kwargs):
294294
"coords_max": [350, 350, 523.9, 180, 180, 180]
295295
},
296296
"MyCobot280": {
297-
"id": [1, 2, 3, 4, 5, 6, 7],
297+
"id": [1, 2, 3, 4, 5, 6],
298298
"angles_min": [-168, -135, -150, -145, -165, -180],
299299
"angles_max": [168, 135, 150, 145, 165, 180],
300300
"coords_min": [-350, -350, -70, -180, -180, -180],
301301
"coords_max": [350, 350, 523.9, 180, 180, 180]
302302
},
303303
"MyCobot280Socket": {
304-
"id": [1, 2, 3, 4, 5, 6, 7],
304+
"id": [1, 2, 3, 4, 5, 6],
305305
"angles_min": [-168, -135, -150, -145, -165, -180],
306306
"angles_max": [168, 135, 150, 145, 165, 180],
307307
"coords_min": [-350, -350, -70, -180, -180, -180],
308308
"coords_max": [350, 350, 523.9, 180, 180, 180]
309309
},
310310
"MyCobot320": {
311-
"id": [1, 2, 3, 4, 5, 6, 7],
311+
"id": [1, 2, 3, 4, 5, 6],
312312
"angles_min": [-170, -137, -151, -148, -169, -180],
313313
"angles_max": [170, 137, 142, 148, 169, 180],
314314
"coords_min": [-350, -350, -41, -180, -180, -180],
315315
"coords_max": [350, 350, 523.9, 180, 180, 180]
316316
},
317317
"MyCobot320Socket": {
318-
"id": [1, 2, 3, 4, 5, 6, 7],
318+
"id": [1, 2, 3, 4, 5, 6],
319319
"angles_min": [-170, -137, -151, -148, -169, -180],
320320
"angles_max": [170, 137, 142, 148, 169, 180],
321321
"coords_min": [-350, -350, -41, -180, -180, -180],
@@ -329,14 +329,14 @@ def calibration_parameters(**kwargs):
329329
"coords_max": [272, 272, 408.9, 180, 180, 180]
330330
},
331331
"MechArm270": {
332-
"id": [1, 2, 3, 4, 5, 6, 7],
332+
"id": [1, 2, 3, 4, 5, 6],
333333
"angles_min": [-165, -90, -180, -165, -115, -175],
334334
"angles_max": [165, 90, 70, 165, 115, 175],
335335
"coords_min": [-272, -272, -36, -180, -180, -180],
336336
"coords_max": [272, 272, 408.9, 180, 180, 180]
337337
},
338338
"MechArmSocket": {
339-
"id": [1, 2, 3, 4, 5, 6, 7],
339+
"id": [1, 2, 3, 4, 5, 6],
340340
"angles_min": [-165, -90, -180, -165, -115, -175],
341341
"angles_max": [165, 90, 70, 165, 115, 175],
342342
"coords_min": [-272, -272, -36, -180, -180, -180],
@@ -372,14 +372,14 @@ def calibration_parameters(**kwargs):
372372
"coords_max": [260, 260, 357.58, 180]
373373
},
374374
"MyPalletizer260": {
375-
"id": [1, 2, 3, 4, 7],
375+
"id": [1, 2, 3, 4],
376376
"angles_min": [-162, -2, -92, -180],
377377
"angles_max": [162, 90, 60, 180],
378378
"coords_min": [-260, -260, -15, -180],
379379
"coords_max": [260, 260, 357.58, 180]
380380
},
381381
"MyPalletizerSocket": {
382-
"id": [1, 2, 3, 4, 7],
382+
"id": [1, 2, 3, 4],
383383
"angles_min": [-162, -2, -92, -180],
384384
"angles_max": [162, 90, 60, 180],
385385
"coords_min": [-260, -260, -15, -180],

pymycobot/mycobotpro630.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import os
1212
import sys
13+
from can import Message
1314
import crc
1415

1516
from pymycobot.log import setup_logging
@@ -2920,6 +2921,89 @@ def tool_gripper_pro_get_torque(self):
29202921
ret = self.tool_serial_read_data(11)
29212922
return int((ret[7] << 8) | (ret[8]))
29222923

2924+
def tool_hand_set_angles(self, angles, speed):
2925+
return self.tool_set_value(
2926+
14,
2927+
45,
2928+
[
2929+
0,
2930+
angles[0],
2931+
0,
2932+
angles[1],
2933+
0,
2934+
angles[2],
2935+
0,
2936+
angles[3],
2937+
0,
2938+
angles[4],
2939+
0,
2940+
angles[5],
2941+
0,
2942+
speed,
2943+
],
2944+
)
2945+
2946+
def tool_hand_open(self, speed=10):
2947+
return self.tool_hand_set_angles([0, 0, 0, 0, 0, 0], speed)
2948+
2949+
def tool_hand_close(self, speed=10):
2950+
return self.tool_hand_set_angles([100, 100, 100, 100, 100, 100], speed)
2951+
2952+
def tool_set_value(self, id, command, parameter):
2953+
"""_summary_
2954+
2955+
send_angles[0,0,0,0,0,0] sp 10:
2956+
07 0xD8 04 14 00 45 00 00
2957+
07 0xD8 03 00 00 00 00 00
2958+
07 0xD8 02 00 00 00 00 00
2959+
04 0xD8 01 00 0a
2960+
2961+
Args:
2962+
id (_type_): _description_
2963+
command (_type_): _description_
2964+
parameter (_type_): _description_
2965+
"""
2966+
command_bytes = command.to_bytes(2, "big")
2967+
if parameter is int:
2968+
parameter_bytes = parameter.to_bytes(2, "big")
2969+
else:
2970+
parameter_bytes = [id, command_bytes[0], command_bytes[1]] + parameter
2971+
messages_number = math.ceil(len(parameter_bytes) / 5)
2972+
for i, sequence in enumerate(range(messages_number, 0, -1)):
2973+
msg_len = 2 + 5
2974+
if sequence == 1:
2975+
msg_len = 2 + (len(parameter_bytes) % 5)
2976+
can_msg = [msg_len, 0xD8, sequence]
2977+
can_msg.extend(parameter_bytes[i * 5 : (i + 1) * 5])
2978+
self._send_can(can_msg)
2979+
2980+
msg = self._receive_can([0x02, 0xD8])
2981+
if msg is Message:
2982+
return bool(msg.data[2])
2983+
2984+
return False
2985+
2986+
def tool_get_value(self, id, command, parameter):
2987+
command_bytes = command.to_bytes(2, "big")
2988+
parameter_bytes = parameter.to_bytes(2, "big")
2989+
self._send_can(
2990+
[
2991+
0x06,
2992+
0xD9,
2993+
id,
2994+
command_bytes[0],
2995+
command_bytes[1],
2996+
parameter_bytes[0],
2997+
parameter_bytes[1],
2998+
]
2999+
)
3000+
msg = self._receive_can([0x06, 0xD9, id, command_bytes[0], command_bytes[1]])
3001+
if msg is Message:
3002+
ret_value = int.from_bytes([msg.data[5], msg.data[6]], "big")
3003+
return ret_value
3004+
3005+
return -1
3006+
29233007
def tool_serial_restore(self):
29243008
"""Restore ESP32 serial."""
29253009
self._send_can([0x01, 0xB1])

0 commit comments

Comments
 (0)