Skip to content

Commit d4f09d5

Browse files
committed
push code
1 parent ac50622 commit d4f09d5

File tree

5 files changed

+302
-62
lines changed

5 files changed

+302
-62
lines changed

pymycobot/Interface.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,20 @@ def _mesg(self, genre, *args, **kwargs):
4444
return real_command, has_reply
4545

4646
# System status
47-
def get_robot_version(self, id):
47+
def get_robot_version(self):
4848
"""Get cobot version
49-
50-
Args:
51-
id: 0/1/2/3 (ALL/L/R/W)
5249
"""
53-
return self._mesg(ProtocolCode.ROBOT_VERSION, id, has_reply=True)
50+
return self._mesg(ProtocolCode.ROBOT_VERSION, 0, has_reply=True)
5451

55-
def get_system_version(self, id):
52+
def get_system_version(self):
5653
"""Get cobot version
57-
58-
Args:
59-
id: 0/1/2/3 (ALL/L/R/W)
6054
"""
61-
return self._mesg(ProtocolCode.SOFTWARE_VERSION, id, has_reply=True)
55+
return self._mesg(ProtocolCode.SOFTWARE_VERSION, 0, has_reply=True)
6256

63-
def get_robot_id(self, id):
57+
def get_robot_id(self):
6458
"""Detect this robot id
65-
66-
Args:
67-
id: 0/1/2/3 (ALL/L/R/W)
6859
"""
69-
return self._mesg(ProtocolCode.GET_ROBOT_ID, id, has_reply=True)
60+
return self._mesg(ProtocolCode.GET_ROBOT_ID, 0, has_reply=True)
7061

7162
def set_robot_id(self, id, new_id):
7263
"""Set this robot id
@@ -232,7 +223,7 @@ def send_coord(self, id, coord, data, speed):
232223
"""Send a single coordinate to the robotic arm
233224
234225
Args:
235-
id: 1/2/3 (L/R/W).
226+
id: 1/2 (L/R).
236227
coord: 1 ~ 6 (x/y/z/rx/ry/rz)
237228
data: Coordinate value
238229
speed: 0 ~ 100
@@ -383,7 +374,7 @@ def jog_angle(self, id, joint_id, direction, speed):
383374
"""Jog control angle.
384375
385376
Args:
386-
id: 1/2/3 (L/R/W).
377+
id: 1/2 (L/R).
387378
joint_id:int 1-6.\n
388379
direction: 0 - decrease, 1 - increase
389380
speed: int (0 - 100)
@@ -394,7 +385,7 @@ def jog_absolute(self, id, joint_id, angle, speed):
394385
"""Absolute joint control
395386
396387
Args:
397-
id: 1/2/3 (L/R/W).
388+
id: 1/2 (L/R).
398389
joint_id: int 1-6.
399390
angle: int
400391
speed: int (0 - 100)
@@ -407,7 +398,7 @@ def jog_coord(self, id, coord_id, direction, speed):
407398
"""Jog control coord.
408399
409400
Args:
410-
id: 1/2/3 (L/R/W).
401+
id: 1/2 (L/R).
411402
coord_id: int 1-6 (x/y/z/rx/ry/rz).
412403
direction: 0 - decrease, 1 - increase
413404
speed: int (0 - 100)
@@ -418,7 +409,7 @@ def jog_increment(self, id, joint_id, increment, speed):
418409
"""step mode
419410
420411
Args:
421-
id: 1/2/3 (L/R/W).
412+
id: 1/2 (L/R).
422413
joint_id: int 1-6.
423414
increment:
424415
speed: int (1 - 100)
@@ -429,7 +420,7 @@ def jog_stop(self, id):
429420
"""Stop jog moving
430421
431422
Args:
432-
id: 1/2/3 (L/R/W).
423+
id: 1/2 (L/R).
433424
"""
434425
return self._mesg(ProtocolCode.JOG_STOP, id)
435426

@@ -515,15 +506,15 @@ def get_acceleration(self, id):
515506
"""Read acceleration during all moves
516507
517508
Args:
518-
id: 1/2/3 (L/R/W)
509+
id: 1/2 (L/R)
519510
"""
520511
return self._mesg(ProtocolCode.GET_ACCELERATION, id, has_reply=True)
521512

522513
def set_acceleration(self, id, acc):
523514
"""Set acceleration during all moves
524515
525516
Args:
526-
id: 1/2/3 (L/R/W)
517+
id: 1/2 (L/R)
527518
acc: 1 - 100
528519
"""
529520
return self._mesg(ProtocolCode.SET_ACCELERATION, id, acc)
@@ -931,7 +922,7 @@ def set_plan_speed(self, id, speed):
931922
"""Set planning speed
932923
933924
Args:
934-
id: 0/1/2/3 (ALL/L/R/W)
925+
id: 0/1/2 (ALL/L/R)
935926
speed (int): (0 ~ 100).
936927
"""
937928
return self._mesg(ProtocolCode.SET_PLAN_SPEED, id, speed)

pymycobot/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from pymycobot.ultraArm import ultraArm
1818
from pymycobot.mybuddybluetooth import MyBuddyBlueTooth
1919
from pymycobot.mypalletizersocket import MyPalletizerSocket
20+
from pymycobot.myarm import MyArm
2021

2122

2223
__all__ = [
@@ -33,15 +34,16 @@
3334
"MyBuddyBlueTooth",
3435
"ultraArm",
3536
"MyPalletizerSocket",
36-
"MechArm"
37+
"MechArm",
38+
"MyArm"
3739
]
3840

3941

4042
if sys.platform == "linux":
4143
from pymycobot.mybuddyemoticon import MyBuddyEmoticon
4244
__all__.append("MyBuddyEmoticon")
4345

44-
__version__ = "2.9.9"
46+
__version__ = "3.0.0b2"
4547
__author__ = "Elephantrobotics"
4648
__email__ = "[email protected]"
4749
__git_url__ = "https://github.com/elephantrobotics/pymycobot"

pymycobot/common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ProtocolCode(object):
4444
GET_ANGLE = 0x2C
4545
GET_COORD = 0x2D
4646
SEND_ANGLES_AUTO = 0x2E
47-
SET_SOLUTION_ANGLES = 0x2E
48-
GET_SOLUTION_ANGLES = 0x2F
47+
GET_SOLUTION_ANGLES = 0x2E
48+
SET_SOLUTION_ANGLES = 0x2F
4949

5050
# JOG MODE AND OPERATION
5151
JOG_ANGLE = 0x30
@@ -289,7 +289,7 @@ def _process_received(self, data, genre, arm=6):
289289

290290
# process valid data
291291
res = []
292-
if data_len in [6, 8, 12, 24, 60]:
292+
if data_len in [6, 8, 12, 14, 24, 60]:
293293
for header_i in range(0, len(valid_data), 2):
294294
one = valid_data[header_i : header_i + 2]
295295
res.append(self._decode_int16(one))
@@ -413,4 +413,5 @@ def read(self, genre):
413413
pre = k
414414
else:
415415
datas = None
416+
self.log.debug("_read: {}".format(datas))
416417
return datas

pymycobot/generate.py

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ def send_angle(self, id, degree, speed):
223223
224224
Args:
225225
id : Joint id(genre.Angle)\n
226-
For mycobot: int 1-6.\n
227-
For mypalletizer: int 1-4.
228-
For mypalletizer 340: int 1-3.
226+
for mycobot: int 1-6.\n
227+
for mypalletizer: int 1-4.
228+
for mypalletizer 340: int 1-3.
229+
for myArm: int 1 - 7.
229230
degree : degree value(float)(about -170 ~ 170).
230231
speed : (int) 0 ~ 100
231232
"""
@@ -241,7 +242,8 @@ def send_angles(self, degrees, speed):
241242
for mycobot: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0].\n
242243
for mypalletizer: [0.0, 0.0, 0.0, 0.0]
243244
for mypalletizer 340: [0.0, 0.0, 0.0]
244-
speed : (int) 0 ~ 100
245+
for myArm: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0].\n
246+
speed : (int) 1 ~ 100
245247
"""
246248
# self.calibration_parameters(degrees=degrees, speed=speed)
247249
degrees = [self._angle2int(degree) for degree in degrees]
@@ -263,9 +265,9 @@ def send_coord(self, id, coord, speed):
263265
264266
Args:
265267
id(int) : coord id(genre.Coord)\n
266-
For mycobot: int 1-6.\n
267-
For mypalletizer: int 1-4.
268-
For mypalletizer 340: int 1-3.
268+
for mycobot: int 1-6.\n
269+
for mypalletizer: int 1-4.
270+
for mypalletizer 340: int 1-3.
269271
coord(float) : coord value, mm
270272
speed(int) : 0 ~ 100
271273
"""
@@ -341,9 +343,10 @@ def jog_angle(self, joint_id, direction, speed):
341343
342344
Args:
343345
joint_id: int
344-
For mycobot: int 1-6.\n
345-
For mypalletizer: int 1-4.
346-
For mypalletizer 340: int 1-3.
346+
for mycobot: int 1-6.\n
347+
for mypalletizer: int 1-4.
348+
for mypalletizer 340: int 1-3.
349+
for myArm: int 1 - 7.
347350
direction: 0 - decrease, 1 - increase
348351
speed: int (0 - 100)
349352
"""
@@ -354,9 +357,9 @@ def jog_coord(self, coord_id, direction, speed):
354357
355358
Args:
356359
coord_id: int
357-
For mycobot: int 1-6.\n
358-
For mypalletizer: int 1-4.
359-
For mypalletizer 340: int 1-3.
360+
for mycobot: int 1-6.\n
361+
for mypalletizer: int 1-4.
362+
for mypalletizer 340: int 1-3.
360363
direction: 0 - decrease, 1 - increase
361364
speed: int (0 - 100)
362365
"""
@@ -367,8 +370,9 @@ def jog_absolute(self, joint_id, angle, speed):
367370
368371
Args:
369372
joint_id: int
370-
For mycobot: int 1-6.\n
371-
For mypalletizer: int 1-4.
373+
for mycobot: int 1-6.\n
374+
for mypalletizer: int 1-4.
375+
for myArm: int 1 - 7.
372376
angle: -180 ~ 180
373377
speed: int (0 - 100)
374378
"""
@@ -378,7 +382,10 @@ def jog_increment(self, joint_id, increment, speed):
378382
"""step mode
379383
380384
Args:
381-
joint_id: int 1-6.
385+
joint_id:
386+
for mycobot: int 1-6.
387+
for mypalletizer: int 1-4.
388+
for myArm: int 1 - 7.
382389
increment:
383390
speed: int (0 - 100)
384391
"""
@@ -418,6 +425,7 @@ def set_encoder(self, joint_id, encoder):
418425
for mycobot: Joint id 1 - 6
419426
for mypalletizer: Joint id 1 - 4
420427
for mycobot gripper: Joint id 7
428+
for myArm: int 1 - 7.
421429
encoder: The value of the set encoder.
422430
"""
423431
return self._mesg(ProtocolCode.SET_ENCODER, joint_id, [encoder])
@@ -426,7 +434,7 @@ def get_encoder(self, joint_id):
426434
"""Obtain the specified joint potential value. (mypalletizer 340 does not have this interface)
427435
428436
Args:
429-
joint_id: (int) 1 ~ 6
437+
joint_id: (int) 1 ~ 7
430438
431439
Returns:
432440
encoder: 0 ~ 4096
@@ -437,8 +445,8 @@ def set_encoders(self, encoders, sp):
437445
"""Set the six joints of the manipulator to execute synchronously to the specified position. (mypalletizer 340 does not have this interface)
438446
439447
Args:
440-
encoders: A encoder list, length 6.
441-
sp: speed 0 ~ 100
448+
encoders: A encoder list.
449+
sp: speed 1 ~ 100
442450
"""
443451
return self._mesg(ProtocolCode.SET_ENCODERS, encoders, sp)
444452

@@ -491,7 +499,11 @@ def get_joint_min_angle(self, joint_id):
491499
"""Gets the minimum movement angle of the specified joint
492500
493501
Args:
494-
joint_id: (int)
502+
joint_id:
503+
for mycobot: Joint id 1 - 6
504+
for mypalletizer: Joint id 1 - 4
505+
for mycobot gripper: Joint id 7
506+
for myArm: int 1 - 7.
495507
496508
Return:
497509
angle value(float)
@@ -503,7 +515,11 @@ def get_joint_max_angle(self, joint_id):
503515
"""Gets the maximum movement angle of the specified joint
504516
505517
Args:
506-
joint_id: (int)
518+
joint_id:
519+
for mycobot: Joint id 1 - 6
520+
for mypalletizer: Joint id 1 - 4
521+
for mycobot gripper: Joint id 7
522+
for myArm: int 1 - 7.
507523
508524
Return:
509525
angle value(float)
@@ -513,10 +529,14 @@ def get_joint_max_angle(self, joint_id):
513529

514530
# Servo control
515531
def is_servo_enable(self, servo_id):
516-
"""Determine whether all steering gears are connected
532+
"""To detect the connection state of a single joint
517533
518534
Args:
519-
servo_id: (int) 1 ~ 6
535+
servo_id:
536+
for mycobot: Joint id 1 - 6
537+
for mypalletizer: Joint id 1 - 4
538+
for mycobot gripper: Joint id 7
539+
for myArm: int 1 - 7.
520540
521541
Return:
522542
0 - disable
@@ -526,7 +546,7 @@ def is_servo_enable(self, servo_id):
526546
return self._mesg(ProtocolCode.IS_SERVO_ENABLE, servo_id, has_reply=True)
527547

528548
def is_all_servo_enable(self):
529-
"""Determine whether the specified steering gear is connected
549+
"""Detect the connection status of all joints
530550
531551
Return:
532552
0 - disable
@@ -539,7 +559,7 @@ def set_servo_data(self, servo_id, data_id, value):
539559
"""Set the data parameters of the specified address of the steering gear
540560
541561
Args:
542-
servo_id: Serial number of articulated steering gear, 1 - 6.
562+
servo_id: Serial number of articulated steering gear, 1 - 7.
543563
data_id: Data address.
544564
value: 0 - 4096
545565
"""
@@ -909,9 +929,10 @@ def set_joint_max(self, id, angle):
909929
910930
Args:
911931
id: int.
912-
For mycobot: int 1-6.\n
913-
For mypalletizer: int 1-4.
914-
For mypalletizer 340: int 1-3.
932+
for mycobot: Joint id 1 - 6
933+
for mypalletizer: Joint id 1 - 4
934+
for mycobot gripper: Joint id 7
935+
for myArm: int 1 - 7.
915936
angle: 0 ~ 180
916937
"""
917938
return self._mesg(ProtocolCode.SET_JOINT_MAX, id, angle)
@@ -921,9 +942,10 @@ def set_joint_min(self, id, angle):
921942
922943
Args:
923944
id: int.
924-
For mycobot: int 1-6.\n
925-
For mypalletizer: int 1-4.\n
926-
For mypalletizer 340: int 1-3.
945+
for mycobot: Joint id 1 - 6
946+
for mypalletizer: Joint id 1 - 4
947+
for mycobot gripper: Joint id 7
948+
for myArm: int 1 - 7.
927949
angle: 0 ~ 180
928950
"""
929951
return self._mesg(ProtocolCode.SET_JOINT_MIN, id, angle)
@@ -944,7 +966,7 @@ def set_encoders_drag(self, encoders, speeds): # TODO 22-5-19 need test
944966
"""Send all encoders and speeds
945967
946968
Args:
947-
encoders: encoders list
969+
encoders: encoders list.
948970
speeds: Obtained by the get_servo_speeds() method
949971
"""
950972
return self._mesg(ProtocolCode.SET_ENCODERS_DRAG, encoders, speeds)
@@ -984,7 +1006,7 @@ def get_servo_last_pdi(self, id):
9841006
"""Obtain the pdi of a single steering gear before modification
9851007
9861008
Args:
987-
id: 1 - 6.0
1009+
id: 1 - 6
9881010
"""
9891011
return self._mesg(ProtocolCode.GET_SERVO_LASTPDI, id, has_reply = True)
9901012

0 commit comments

Comments
 (0)