@@ -367,26 +367,140 @@ def clear_all_errors(self):
367
367
while self .read_next_error () != "" :
368
368
pass
369
369
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()
370
481
def write_coords (self , coords , speed ):
371
482
command = "set_coords("
372
483
for item in coords :
373
484
command += str (round (item , 3 )) + ","
374
485
command += str (speed ) + ")\n "
375
486
self .send_command (command )
376
487
488
+ # TODO: change to set_coord() socket API (already impemented)
377
489
def write_coord (self , axis , value , speed ):
378
490
coords = self .get_coords ()
379
491
if coords != self .invalid_coords ():
380
492
coords [axis ] = value
381
493
self .write_coords (coords , speed )
382
494
495
+ # TODO: rename to set_angles()
383
496
def write_angles (self , angles , speed ):
384
497
command = "set_angles("
385
498
for item in angles :
386
499
command += str (round (item , 3 )) + ","
387
500
command += str (speed ) + ")\n "
388
501
self .send_command (command )
389
502
503
+ # TODO: change to set_angle() socket API (already impemented)
390
504
def write_angle (self , joint , value , speed ):
391
505
angles = self .get_angles ()
392
506
if angles != self .invalid_coords ():
0 commit comments