Skip to content

Commit 40d4e8c

Browse files
author
Leonid Fedorenchik
committed
feat(Pro630): Add new APIs
1 parent 745c93e commit 40d4e8c

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

pymycobot/elephantrobot.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,26 +367,140 @@ def clear_all_errors(self):
367367
while self.read_next_error() != "":
368368
pass
369369

370+
def get_robot_state(self) -> str:
371+
"""Returns current robot state, which is 64 bits represented as a
372+
string of 64 zeroes or ones.
373+
374+
Meaning of each bit from eft to right is as follows:
375+
Bit number | Meaning
376+
0 | Power on
377+
1 | Emergency stop button, 0 - pressed, 1 - released
378+
2 | Joint 6 status, 0 - error, 1 - OK
379+
3 | Joint 5 status, 0 - error, 1 - OK
380+
4 | Joint 4 status, 0 - error, 1 - OK
381+
5 | Joint 3 status, 0 - error, 1 - OK
382+
6 | Joint 2 status, 0 - error, 1 - OK
383+
7 | Joint 1 status, 0 - error, 1 - OK
384+
8 | Reserved
385+
9 | Reserved
386+
10 | Reserved
387+
11 | Motion enabled, 0 - disabled, 1 - enabled
388+
12 | Hardware Free Move
389+
13 | Joint 6 servo enabled, 0 - disabled, 1 - enabled
390+
14 | Joint 5 servo enabled, 0 - disabled, 1 - enabled
391+
15 | Joint 4 servo enabled, 0 - disabled, 1 - enabled
392+
16 | Joint 3 servo enabled, 0 - disabled, 1 - enabled
393+
17 | Joint 2 servo enabled, 0 - disabled, 1 - enabled
394+
18 | Joint 1 servo enabled, 0 - disabled, 1 - enabled
395+
19 | Brake activation running, 0 - not running, 1 - running
396+
20 | Hardware Pause Pressed, 0 - not pressed, 1 - pressed
397+
21 | Reserved
398+
22 | IO Run Triggered, 0 - not triggered, 1 - triggered
399+
23 | IO Stop Triggered, 0 - not triggered, 1 - triggered
400+
24 | Joint 6 communication status, 0 - error, 1 - OK
401+
25 | Joint 5 communication status, 0 - error, 1 - OK
402+
26 | Joint 4 communication status, 0 - error, 1 - OK
403+
27 | Joint 3 communication status, 0 - error, 1 - OK
404+
28 | Joint 2 communication status, 0 - error, 1 - OK
405+
29 | Joint 1 communication status, 0 - error, 1 - OK
406+
30 | Collision detected, 0 - not detected, 1 - detected
407+
31 | Reserved
408+
32 | Reserved
409+
33 | Reserved
410+
34 | Reserved
411+
35 | Reserved
412+
36 | Reserved
413+
37 | Reserved
414+
38 | Reserved
415+
39 | Reserved
416+
40 | Reserved
417+
41 | Reserved
418+
42 | Reserved
419+
43 | Reserved
420+
44 | Reserved
421+
45 | Reserved
422+
46 | C Series Physical User button
423+
47 | C Series Physical Stop button
424+
48 | C Series Physical Start button
425+
49 | Reserved
426+
50 | Reserved
427+
51 | Reserved
428+
52 | Reserved
429+
53 | Reserved
430+
54 | Reserved
431+
55 | Reserved
432+
56 | Reserved
433+
57 | Reserved
434+
58 | Reserved
435+
59 | Reserved
436+
60 | Reserved
437+
61 | Reserved
438+
62 | Reserved
439+
63 | Reserved
440+
441+
For example, if robot is powered on, enabled and in position,
442+
the returned string will be:
443+
'1011111100000111111000001111110000000000000000110000000000000000'
444+
445+
Returns:
446+
str: robot state as a string of 64 zeroes or ones.
447+
"""
448+
command = "get_robot_state()\n"
449+
res = self.send_command(command)
450+
return res
451+
452+
def set_servos_calibration(self) -> str:
453+
"""Sets servos calibration, that is, current robot pose will become
454+
robot's zero position.
455+
456+
This function will shutdown robot. You will need to restart the robot
457+
and reconnect to continue working with it.
458+
459+
Returns:
460+
str: empty string if success, error message otherwise.
461+
"""
462+
command = "set_servos_calibration()\n"
463+
res = self.send_command(command)
464+
return res
465+
466+
def get_joint_loss_pkg(self, joint_number: Joint) -> int:
467+
"""Retrieves the loss package count for a specific joint.
468+
469+
Args:
470+
joint_number (Joint): The joint number for which the loss package
471+
value is requested.
472+
473+
Returns:
474+
int: The loss package count for the specified joint.
475+
"""
476+
command = "get_joint_loss_pkg(" + str(joint_number) + ")\n"
477+
res = self.send_command(command)
478+
return int(self.string_to_double(res))
479+
480+
# TODO: rename to set_coords()
370481
def write_coords(self, coords, speed):
371482
command = "set_coords("
372483
for item in coords:
373484
command += str(round(item, 3)) + ","
374485
command += str(speed) + ")\n"
375486
self.send_command(command)
376487

488+
# TODO: change to set_coord() socket API (already impemented)
377489
def write_coord(self, axis, value, speed):
378490
coords = self.get_coords()
379491
if coords != self.invalid_coords():
380492
coords[axis] = value
381493
self.write_coords(coords, speed)
382494

495+
# TODO: rename to set_angles()
383496
def write_angles(self, angles, speed):
384497
command = "set_angles("
385498
for item in angles:
386499
command += str(round(item, 3)) + ","
387500
command += str(speed) + ")\n"
388501
self.send_command(command)
389502

503+
# TODO: change to set_angle() socket API (already impemented)
390504
def write_angle(self, joint, value, speed):
391505
angles = self.get_angles()
392506
if angles != self.invalid_coords():

0 commit comments

Comments
 (0)