Skip to content

Cartesian movement

This page contains information on all functions present within move_cartesian.py and aims to give a clear understanding both of what these functions do and the requirements for any data to be input into them.

These functions allow for handling of all different types of movement allowed within the original python sdk

Functions

cartesian_control

Source code in actions\move_cartesian.py
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
class cartesian_control():

    def __init__(self, arm:XArmAPI):
        self.arm = arm

    def reset(self, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None):
        """
        Reset the xArm

        Warning:
            without limit detection

        Note:
            1. If there are errors or warnings, this interface will clear the warnings and errors.
            2. If not ready, the api will auto enable motion and set state
            3. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc

        Args:
            speed: reset speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

            mvacc: reset acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

            mvtime: reserved

            is_radian: if the speed and acceleration are in radians or not, defaults to self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True
        """
        return self.arm.reset(speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout)

    def set_position(self, x=None, y=None, z=None, roll=None, pitch=None, yaw=None, radius=None,
                     speed=None, mvacc=None, mvtime=None, relative=False, is_radian=None,
                     wait=False, timeout=None, **kwargs):
        """
        Set the cartesian position, the API will modify self.last_used_position value

        Note:
            1. If it is xArm5, roll must be set to 180° or π rad, pitch must be set to 0
            2. If the parameter(roll/pitch/yaw) you are passing is an radian unit, set is_radian to True.
                ex: code = arm.set_position(x=300, y=0, z=200, roll=-3.14, pitch=0, yaw=0, is_radian=True)
            3. If you want to wait for the robot to complete this action and then return, set wait to True.
                ex: code = arm.set_position(x=300, y=0, z=200, roll=180, pitch=0, yaw=0, is_radian=False, wait=True)
            4. This interface is only used in the base coordinate system.

        Args:
            x: cartesian position x, (mm), default is self.last_used_position[0]

            y: cartesian position y, (mm), default is self.last_used_position[1]

            z: cartesian position z, (mm), default is self.last_used_position[2]

            roll: rotate around the X axis, (unit: rad if is_radian is True else °), default is self.last_used_position[3]

            pitch: rotate around the Y axis, (unit: rad if is_radian is True else °), default is self.last_used_position[4]

            yaw: rotate around the Z axis, (unit: rad if is_radian is True else °), default is self.last_used_position[5]

            radius: move radius, if radius is None or radius less than 0, will MoveLine, else MoveArcLine

                MoveLine: Linear motion

                - ex: code = arm.set_position(..., radius=None)

                MoveArcLine: Linear arc motion with interpolation

                - ex: code = arm.set_position(..., radius=0)

                - Note: Need to set radius>=0

            speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

            mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

            mvtime: 0, reserved

            relative: relative move or not

            is_radian: the roll/pitch/yaw in radians or not, default is self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

            kwargs: extra parameters

                motion_type: motion planning type, default is 0

                - motion_type == 0: default, linear planning

                - motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

                - motion_type == 2: direct transfer to IK using joint planning

                Note: 

                1. only available if firmware_version >= 1.11.100

                2. when motion_type is 1 or 2, linear motion cannot be guaranteed

                3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                    speed = speed / max_tcp_speed * max_joint_speed

                    mvacc = mvacc / max_tcp_acc * max_joint_acc

                4. if there is no suitable IK, a C40 error will be triggered

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

                code < 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will not be modified

                code >= 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified
        """
        return self.arm.set_position(x=x, y=y, z=z, roll=roll, pitch=pitch, yaw=yaw, radius=radius,
                                      speed=speed, mvacc=mvacc, mvtime=mvtime, relative=relative,
                                      is_radian=is_radian, wait=wait, timeout=timeout, **kwargs)

    def set_servo_angle(self, servo_id=None, angle=None, speed=None, mvacc=None, mvtime=None,
                        relative=False, is_radian=None, wait=False, timeout=None, radius=None, **kwargs):
        """
        Set the servo angle, the API will modify self.last_used_angles value

        Note:
           1. If the parameter angle you are passing is an radian unit, be sure to set the parameter is_radian to True.
                ex: code = arm.set_servo_angle(servo_id=1, angle=1.57, is_radian=True)
            2. If you want to wait for the robot to complete this action and then return, please set the parameter wait to True.
                ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False,wait=True)
            3. This interface is only used in the base coordinate system.

        Args:
            servo_id: 1-(Number of axes), None(8)

                1. 1-(Number of axes) indicates the corresponding joint, the parameter angle should be a numeric value

                    ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

                2. None(8) means all joints, default is None, the parameter angle should be a list of values whose length is the number of joints

                    ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

            angle: angle or angle list, (unit: rad if is_radian is True else °)

                1. If servo_id is 1-(Number of axes), angle should be a numeric value

                    ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

                2. If servo_id is None or 8, angle should be a list of values whose length is the number of joints

                    like [axis-1, axis-2, axis-3, axis-4, axis-5, axis-6, axis-7]

                    ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

            speed: move speed (unit: rad/s if is_radian is True else °/s), default is self.last_used_joint_speed

            mvacc: move acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is self.last_used_joint_acc

            mvtime: 0, reserved

            relative: relative move or not

            is_radian: the angle in radians or not, default is self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

            radius: move radius, if radius is None or radius less than 0, will MoveJoint, else MoveArcJoint

                Note: Only available if version > 1.5.20

                Note: The blending radius cannot be greater than the track length.

                MoveJoint: joint motion

                - ex: code = arm.set_servo_angle(..., radius=None)

                MoveArcJoint: joint fusion motion with interpolation

                - ex: code = arm.set_servo_angle(..., radius=0)

                - Note: Need to set radius>=0

            kwargs: reserved

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
                code < 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified

                code >= 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will be modified
        """
        return self.arm.set_servo_angle(servo_id=servo_id, angle=angle, speed=speed, mvacc=mvacc, mvtime=mvtime,relative=relative, is_radian=is_radian, wait=wait, timeout=timeout, radius=radius, **kwargs)

    def get_servo_angle(self, servo_id=None, is_radian=None, is_real=False):
        """
        returns the servo angle

        Note:
            1. if value returned should be in radians, please set is_radian to True
            2. If you want to return only the angle of a single joint, please set the parameter servo_id
                ex: code, angle = arm.get_servo_angle(servo_id=2)
            3. This interface is only used in the base coordinate system.

        Args:
            servo_id: 1-(Number of axes), None(8), default is None

            is_radian: the returned value is in radians or not, default is self.default_is_radian

        Returns:
            out tuple[int, float | list[float]]: tuple((code, angle list if servo_id is None or 8 else angle)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            angle (float | list[float]): angle or list of angles depending on servo_id, unit depends on is_radian
        """
        return self.arm.get_servo_angle(servo_id=servo_id, is_radian=is_radian, is_real=is_real)

    def set_servo_angle_j(self, angles, speed=None, mvacc=None, mvtime=None, is_radian=None, **kwargs):
        """
        Set the servo angle, execute only the last instruction, need to be set to servo motion mode(self.set_mode(1))

        Note:
            1. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc
            2. This interface is only used in the base coordinate system.

        Args:
            angles: angle list, (unit: rad if is_radian is True else °)

            speed: speed, reserved

            mvacc: acceleration, reserved

            mvtime: 0, reserved

            is_radian: if the angles are in radians or not, default is self.default_is_radian

            kwargs: reserved

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_servo_angle_j(angles, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, **kwargs)

    def set_servo_cartesian(self, mvpose, speed=None, mvacc=None, mvtime=0, is_radian=None, is_tool_coord=False, **kwargs):
        """
        Set the servo to cartesian, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

        Args:
            mvpose: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

            speed: move speed (mm/s), reserved

            mvacc: move acceleration (mm/s^2), reserved

            mvtime: 0, reserved

            is_radian: if the roll/pitch/yaw of mvpose are in radians or not, default is self.default_is_radian

            is_tool_coord: is tool coordinate or not

            kwargs: reserved

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_servo_cartesian(mvpose, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian,
                                             is_tool_coord=is_tool_coord, **kwargs)

    def move_circle(self, pose1, pose2, percent, speed=None, mvacc=None, mvtime=None, is_radian=None,
                    wait=False, timeout=None, is_tool_coord=False, is_axis_angle=False, **kwargs):
        """
        The motion calculates the trajectory of the space circle according to the three-point coordinates.
        The three-point coordinates are (current starting point, pose1, pose2).


        Args:
            pose1: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

            pose2: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

            percent: the percentage of arc length and circumference of the movement

            speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

            mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

            mvtime: 0, reserved

            is_radian: if roll/pitch/yaw values are in radians or not, default is self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

            is_tool_coord: is tool coord or not, default is False, only available if firmware_version >= 1.11.100

            is_axis_angle: is axis angle or not, default is False, only available if firmware_version >= 1.11.100

            kwargs: reserved

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

                code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

                code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified
        """
        return self.arm.move_circle(pose1, pose2, percent, speed=speed, mvacc=mvacc, mvtime=mvtime,
                                     is_radian=is_radian, wait=wait, timeout=timeout,
                                     is_tool_coord=is_tool_coord, is_axis_angle=is_axis_angle, **kwargs)

    def move_gohome(self, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None, **kwargs):
        """
        Move to go home (Back to zero)

        Warning:
        without limit detection

        Note:
            1. If you want to wait for the robot to complete it's current action and then return, set wait to True.
                ex: code = arm.move_gohome(wait=True)
            2. This interface does not modify the value of last_used_joint_speed/last_used_joint_acc

        Args:
            speed: gohome speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

            mvacc: gohome acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

            mvtime: reserved

            is_radian: if the speed and acceleration are in radians or not, default is self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.move_gohome(speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout, **kwargs)

    def emergency_stop(self):
        """
        Emergency stop (set_state(4) -> motion_enable(True) -> set_state(0))

        Note:
            1. This interface does not automatically clear errors. If there is an error, you will need to handle it according to the error code.
        """
        return self.arm.emergency_stop()

    def set_position_aa(self, axis_angle_pose, speed=None, mvacc=None, mvtime=None,
                        is_radian=None, is_tool_coord=False, relative=False, wait=False, timeout=None, radius=None, **kwargs):
        """
        Set the pose represented by the axis angle pose

        Args:
            axis_angle_pose: the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

            speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

            mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

            mvtime: 0, reserved 

            is_radian: if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

            is_tool_coord: is tool coordinate or not, if True, the relative parameter is no longer valid

            relative: relative move or not

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

            radius: move radius, if radius is None or radius less than 0, will MoveLineAA, else MoveArcLineAA
                only available if firmware_version >= 1.11.100

                MoveLineAA: Linear motion

                    - ex: code = arm.set_position_aa(..., radius=None)

                MoveArcLineAA: Linear arc motion with interpolation

                    - ex: code = arm.set_position_aa(..., radius=0)

                    - Note: Need to set radius>=0

            kwargs: extra parameters

                - motion_type: motion planning type, default is 0

                    - motion_type == 0: default, linear planning

                    - motion_type == 2: direct transfer to IK using joint planning

                    Note:

                    1. only available if firmware_version >= 1.11.100

                    2. when motion_type is 1 or 2, linear motion cannot be guaranteed

                    3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                        speed = speed / max_tcp_speed * max_joint_speed

                        mvacc = mvacc / max_tcp_acc * max_joint_acc

                    4. if there is no suitable IK, a C40 error will be triggered

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_position_aa(axis_angle_pose, speed=speed, mvacc=mvacc, mvtime=mvtime,
                                         is_radian=is_radian, is_tool_coord=is_tool_coord, relative=relative,
                                         wait=wait, timeout=timeout, radius=radius, **kwargs)

    def set_servo_cartesian_aa(self, axis_angle_pose, speed=None, mvacc=None, is_radian=None, is_tool_coord=False, relative=False, **kwargs):
        """
        Set the servo cartesian represented by the axis angle pose, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

        Note:
            1. only available if firmware_version >= 1.4.7

        Args:
            axis_angle_pose: the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

            speed: move speed (mm/s), reserved

            mvacc: move acceleration (mm/s^2), reserved

            is_radian: if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

            is_tool_coord: is tool coordinate or not

            relative: relative move or not

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """

        return self.arm.set_servo_cartesian_aa(axis_angle_pose, speed=speed, mvacc=mvacc, is_radian=is_radian,
                                                is_tool_coord=is_tool_coord, relative=relative, **kwargs)

    def vc_set_joint_velocity(self, speeds, is_radian=None, is_sync=True, duration=-1, **kwargs):
        """
        Joint velocity control, need to be in joint velocity control mode(self.set_mode(4))

        Note:
            1. only available if firmware_version >= 1.6.9

        Args:
            speeds: [spd_J1, spd_J2, ..., spd_J7]

            is_radian: if the spd_Jx is in radians or not, default is self.default_is_radian

            is_sync: whether all joints accelerate and decelerate synchronously, default is True

            duration: The duration of this speed command, over this time will automatically set the speed to 0

                Note: only available if firmware_version >= 1.8.0

                duration > 0: seconds

                duration == 0: Always effective, will not stop automatically

                duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.vc_set_joint_velocity(speeds, is_radian=is_radian, is_sync=is_sync, duration=duration, **kwargs)

    def vc_set_cartesian_velocity(self, speeds, is_radian=None, is_tool_coord=False, duration=-1, **kwargs):
        """
        Cartesian velocity control, need to be in cartesian velocity control mode(self.set_mode(5))

        Note:
            1. only available if firmware_version >= 1.6.9

        Args:
            speeds: [spd_x, spd_y, spd_z, spd_rx, spd_ry, spd_rz]

            is_radian: if the spd_rx/spd_ry/spd_rz are in radians or not, default is self.default_is_radian

            is_tool_coord: is tool coordinate or not, default is False

            duration: the maximum duration of the speed, over this time will automatically set the speed to 0

                Note: only available if firmware_version >= 1.8.0

                duration > 0: seconds, indicates the maximum number of seconds that this speed can be maintained

                duration == 0: Always effective, will not stop automatically

                duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.vc_set_cartesian_velocity(speeds, is_radian=is_radian, is_tool_coord=is_tool_coord, duration=duration, **kwargs)

    def get_linear_motor_registers(self, **kwargs):
        """
        Get the status of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, dict]): tuple((code, status)), returned result is only corrent when code is 0.

            code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            status (dict): status, like
                {
                    'pos': 0,
                    'status': 0,
                    'error': 0,
                    'is_enabled': 0,
                    'on_zero': 0,
                    'sci': 1,
                    'sco': [0, 0],
                }
        """
        return self.arm.get_linear_motor_registers(**kwargs)

    def get_linear_motor_pos(self):
        """
        Get the pos of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, position)) returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            position (int): position
        """
        return self.arm.get_linear_motor_pos()

    def get_linear_motor_status(self):
        """
        Get the status of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

            code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            status (int): status

                status & 0x00: motion finish

                status & 0x01: in motion

                status & 0x02: has stop
        """
        return self.arm.get_linear_motor_status()

    def get_linear_motor_error(self):
        """
        Get the error code of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, error)), returned result is only corrent when code is 0.

            code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            error (int): See the [Linear Motor Error Code Documentation](./xarm_api_code.md#linear-motor-error-code) for details.
        """
        return self.arm.get_linear_motor_error()

    def get_linear_motor_is_enabled(self):
        """
        Get if the linear motor is enabled or not

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            status (int):

                0: linear motor is not enabled

                1: linear motor is enabled
        """
        return self.arm.get_linear_motor_is_enabled()

    def get_linear_motor_on_zero(self):
        """
        Get if the linear motor is on zero positon or not

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            status (int):

                0: linear motor is not on zero

                1: linear motor is on zero
        """
        return self.arm.get_linear_motor_on_zero()

    def get_linear_motor_sci(self):
        """
        Get the sci1 value of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, int]): tuple((code, sci1)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            sci1 (int): sci1 value
        """
        return self.arm.get_linear_motor_sci()

    def get_linear_motor_sco(self):
        """
        Get the sco value of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            out (tuple[int, list]): tuple((code, sco)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            sco (list[int]): [sco0, sco1]
        """
        return self.arm.get_linear_motor_sco()

    def clean_linear_motor_error(self):
        """
        Clean the linear motor error

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.clean_linear_motor_error()

    def set_linear_motor_enable(self, enable):
        """
        Set the linear motor enable/disable

        Note:
            1. only available if firmware_version >= 1.8.0

        Args:
            enable: enable or not

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_linear_motor_enable(enable)

    def set_linear_motor_speed(self, speed):
        """
        Set the speed of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Args:
            speed: Integer between 1 and 1000mm/s.

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_linear_motor_speed(speed)

    def set_linear_motor_back_origin(self, wait=True, **kwargs):
        """
        Set the linear motor to go back to the origin position

        Note:
            1. only available if firmware_version >= 1.8.0
            2. only useful when powering on for the first time
            3. this operation must be performed at the first power-on

        Args:
            wait: wait to motion finish or not, default is True

            kwargs:
                auto_enable: enable after back to origin or not, default is True

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_linear_motor_back_origin(wait=wait, **kwargs)

    def set_linear_motor_pos(self, pos, speed=None, wait=True, timeout=100, **kwargs):
        """
        Set the position of the linear motor

        Note:
            1. only available if firmware_version >= 1.8.0

        Args:
            pos: position. Integer between 0 and 700/1000/1500mm.

                If SN start with AL1300 the position range is 0~700mm.

                If SN start with AL1301 the position range is 0~1000mm.

                If SN start with AL1302 the position range is 0~1500mm.

            speed: speed of the linear motor. Integer between 1 and 1000mm/s. default is not set

            wait: wait to motion finish or not, default is True

            timeout: wait timeout, seconds, default is 100s.

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_linear_motor_pos(pos, speed=speed, wait=wait, timeout=timeout, **kwargs)

    def set_linear_motor_stop(self):
        """
        Set the linear motor to stop

        Note:
            1. only available if firmware_version >= 1.8.0

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_linear_motor_stop()

    def set_tool_position(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0,
                          speed=None, mvacc=None, mvtime=None, is_radian=None,
                          wait=False, timeout=None, radius=None, **kwargs):
        """
        Movement relative to the tool coordinate system

        Note:
            1. This interface is moving relative to the current tool coordinate system
            2. The tool coordinate system is not fixed and varies with position.
            3. This interface is only used in the tool coordinate system.


        Args:
            x: the x coordinate relative to the current tool coordinate system, (unit: mm), default 0

            y: the y coordinate relative to the current tool coordinate system, (unit: mm), default 0

            z: the z coordinate relative to the current tool coordinate system, (unit: mm), default 0

            roll: the rotation around the X axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

            pitch: the rotation around the Y axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

            yaw: the rotation around the Z axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

            speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

            mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

            mvtime: 0, reserved

            is_radian: if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

            wait: whether to wait for the arm to complete, default is False

            timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

            radius: move radius, if radius is None or radius less than 0, will MoveToolLine, else MoveToolArcLine

                only available if firmware_version >= 1.11.100

                MoveToolLine: Linear motion

                - ex: code = arm.set_tool_position(..., radius=None)

                MoveToolArcLine: Linear arc motion with interpolation

                - ex: code = arm.set_tool_position(..., radius=0)

                - Note: Need to set radius>=0

            kwargs: extra parameters

                motion_type: motion planning type, default is 0

                - motion_type == 0: default, linear planning

                - motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

                - motion_type == 2: direct transfer to IK using joint planning

                Note: 

                1. only available if firmware_version >= 1.11.100

                2. when motion_type is 1 or 2, linear motion cannot be guaranteed

                3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                    speed = speed / max_tcp_speed * max_joint_speed

                    mvacc = mvacc / max_tcp_acc * max_joint_acc

                4. if there is no suitable IK, a C40 error will be triggered

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

                code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

                code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified
        """
        return self.arm.set_tool_position(x=x, y=y, z=z, roll=roll, pitch=pitch, yaw=yaw, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout, radius=radius, **kwargs)

    def move_arc_lines(self, paths, is_radian=None, times=1, first_pause_time=0.1, repeat_pause_time=0,
                       automatic_calibration=True, speed=None, mvacc=None, mvtime=None, wait=False):
        """
        Continuous linear motion with interpolation.

        Note:
            1. If an error occurs, it will return early.
            2. If the emergency_stop interface is called actively, it will return early.
            3. The last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified.
            4. The last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified.

        Args:
            paths: cartesian path list
                1. Specify arc radius: [[x, y, z, roll, pitch, yaw, radius], ....]

                2. Do not specify arc radius (radius=0): [[x, y, z, roll, pitch, yaw], ....]

                3. If you want to plan the continuous motion,set radius>0.

            is_radian: if roll/pitch/yaw of the paths are in radians or not, default is self.default_is_radian

            times: amount of times to repeat, 0 is infinite loop, default is 1

            first_pause_time: sleep time at first, purpose is to cache the commands and plan continuous motion, default is 0.1s

            repeat_pause_time: interval between repeated movements, unit: (s)second

            automatic_calibration: automatic calibration or not, default is True

            speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

            mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

            mvtime: 0, reserved

            wait: whether to wait for the arm to complete, default is False
        """
        return self.arm.move_arc_lines(paths, is_radian=is_radian, times=times, first_pause_time=first_pause_time,
                                        repeat_pause_time=repeat_pause_time, automatic_calibration=automatic_calibration,
                                        speed=speed, mvacc=mvacc, mvtime=mvtime, wait=wait)

    def get_trajectories(self):
        """
        Get the trajectories

        Note:
            1. This interface relies on xArmStudio 1.2.0 or above
            2. This interface relies on Firmware 1.2.0 or above

        Returns:
            out (tuple[int, list]): tuple((code, trajectories))

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            trajectories (list): [{

                'name'- name, The name of the trajectory

                'duration'- duration, The duration of the trajectory (seconds)

                }]
        """
        return self.arm.get_trajectories()

    def set_world_offset(self, offset, is_radian=None, wait=True):
        """
        Set the base coordinate offset

        Note:
            1. This interface relies on Firmware 1.2.11 or above

        Args:
            offset: [x, y, z, roll, pitch, yaw]

            is_radian: if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

            wait: whether to wait for the robotic arm to stop or all previous queue commands to be executed or cleared before setting

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_world_offset(offset, is_radian=is_radian, wait=wait)

    def get_pose_offset(self, pose1, pose2, orient_type_in=0, orient_type_out=0, is_radian=None):
        """
        Calculate the pose offset of two given points

        Args:
            pose1: [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

            pose2: [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

            orient_type_in: input attitude notation, 0 is RPY(roll/pitch/yaw) (default), 1 is axis angle(rx/ry/rz)

            orient_type_out: notation of output attitude, 0 is RPY (default), 1 is axis angle

            is_radian: if the roll/rx/pitch/ry/yaw/rz of pose1/pose2/return_pose is radian or not

        Returns:
            out (tuple[int, list]): tuple((code, pose)), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            pose (list[float]): [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]
        """
        return self.arm.get_pose_offset(pose1, pose2, orient_type_in=orient_type_in, orient_type_out=orient_type_out,
                                         is_radian=is_radian)

    def get_position_aa(self, is_radian=None):
        """
        Get the pose represented by the axis angle pose

        Args:
            is_radian: the returned value (only rx/ry/rz) is in radians or not, default is self.default_is_radian

        Returns:
            out (tuple[int, list]): tuple((code, [x, y, z, rx, ry, rz])), returned result is only corrent when code is 0.

            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.get_position_aa(is_radian=is_radian)

    def set_cartesian_velo_continuous(self, on_off):
        """
        Set cartesian motion velocity continuous

        Note:
            1. only available if firmware_version >= 1.9.0

        Args:
            on_off: continuous or not, True means continuous, default is False

        Returns:
            code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
        """
        return self.arm.set_cartesian_velo_continuous(on_off)

clean_linear_motor_error()

Clean the linear motor error

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
657
658
659
660
661
662
663
664
665
666
667
def clean_linear_motor_error(self):
    """
    Clean the linear motor error

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.clean_linear_motor_error()

emergency_stop()

Emergency stop (set_state(4) -> motion_enable(True) -> set_state(0))

Note
  1. This interface does not automatically clear errors. If there is an error, you will need to handle it according to the error code.
Source code in actions\move_cartesian.py
346
347
348
349
350
351
352
353
def emergency_stop(self):
    """
    Emergency stop (set_state(4) -> motion_enable(True) -> set_state(0))

    Note:
        1. This interface does not automatically clear errors. If there is an error, you will need to handle it according to the error code.
    """
    return self.arm.emergency_stop()

get_linear_motor_error()

Get the error code of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, error)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

error int
Source code in actions\move_cartesian.py
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
def get_linear_motor_error(self):
    """
    Get the error code of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, error)), returned result is only corrent when code is 0.

        code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        error (int): See the [Linear Motor Error Code Documentation](./xarm_api_code.md#linear-motor-error-code) for details.
    """
    return self.arm.get_linear_motor_error()

get_linear_motor_is_enabled()

Get if the linear motor is enabled or not

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, status)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

status int

0: linear motor is not enabled

1: linear motor is enabled

Source code in actions\move_cartesian.py
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
def get_linear_motor_is_enabled(self):
    """
    Get if the linear motor is enabled or not

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        status (int):

            0: linear motor is not enabled

            1: linear motor is enabled
    """
    return self.arm.get_linear_motor_is_enabled()

get_linear_motor_on_zero()

Get if the linear motor is on zero positon or not

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, status)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

status int

0: linear motor is not on zero

1: linear motor is on zero

Source code in actions\move_cartesian.py
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
def get_linear_motor_on_zero(self):
    """
    Get if the linear motor is on zero positon or not

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        status (int):

            0: linear motor is not on zero

            1: linear motor is on zero
    """
    return self.arm.get_linear_motor_on_zero()

get_linear_motor_pos()

Get the pos of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, position)) returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

position int

position

Source code in actions\move_cartesian.py
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
def get_linear_motor_pos(self):
    """
    Get the pos of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, position)) returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        position (int): position
    """
    return self.arm.get_linear_motor_pos()

get_linear_motor_registers(**kwargs)

Get the status of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, dict]

tuple((code, status)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

status dict

status, like { 'pos': 0, 'status': 0, 'error': 0, 'is_enabled': 0, 'on_zero': 0, 'sci': 1, 'sco': [0, 0], }

Source code in actions\move_cartesian.py
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
def get_linear_motor_registers(self, **kwargs):
    """
    Get the status of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, dict]): tuple((code, status)), returned result is only corrent when code is 0.

        code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        status (dict): status, like
            {
                'pos': 0,
                'status': 0,
                'error': 0,
                'is_enabled': 0,
                'on_zero': 0,
                'sci': 1,
                'sco': [0, 0],
            }
    """
    return self.arm.get_linear_motor_registers(**kwargs)

get_linear_motor_sci()

Get the sci1 value of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, sci1)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

sci1 int

sci1 value

Source code in actions\move_cartesian.py
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
def get_linear_motor_sci(self):
    """
    Get the sci1 value of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, sci1)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        sci1 (int): sci1 value
    """
    return self.arm.get_linear_motor_sci()

get_linear_motor_sco()

Get the sco value of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, list]

tuple((code, sco)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

sco list[int]

[sco0, sco1]

Source code in actions\move_cartesian.py
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
def get_linear_motor_sco(self):
    """
    Get the sco value of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, list]): tuple((code, sco)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        sco (list[int]): [sco0, sco1]
    """
    return self.arm.get_linear_motor_sco()

get_linear_motor_status()

Get the status of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
out tuple[int, int]

tuple((code, status)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

status int

status

status & 0x00: motion finish

status & 0x01: in motion

status & 0x02: has stop

Source code in actions\move_cartesian.py
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
def get_linear_motor_status(self):
    """
    Get the status of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        out (tuple[int, int]): tuple((code, status)), returned result is only corrent when code is 0.

        code (int):  See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        status (int): status

            status & 0x00: motion finish

            status & 0x01: in motion

            status & 0x02: has stop
    """
    return self.arm.get_linear_motor_status()

get_pose_offset(pose1, pose2, orient_type_in=0, orient_type_out=0, is_radian=None)

Calculate the pose offset of two given points

Parameters:

Name Type Description Default
pose1

[x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

required
pose2

[x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

required
orient_type_in

input attitude notation, 0 is RPY(roll/pitch/yaw) (default), 1 is axis angle(rx/ry/rz)

0
orient_type_out

notation of output attitude, 0 is RPY (default), 1 is axis angle

0
is_radian

if the roll/rx/pitch/ry/yaw/rz of pose1/pose2/return_pose is radian or not

None

Returns:

Name Type Description
out tuple[int, list]

tuple((code, pose)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

pose list[float]

[x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

Source code in actions\move_cartesian.py
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
def get_pose_offset(self, pose1, pose2, orient_type_in=0, orient_type_out=0, is_radian=None):
    """
    Calculate the pose offset of two given points

    Args:
        pose1: [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

        pose2: [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]

        orient_type_in: input attitude notation, 0 is RPY(roll/pitch/yaw) (default), 1 is axis angle(rx/ry/rz)

        orient_type_out: notation of output attitude, 0 is RPY (default), 1 is axis angle

        is_radian: if the roll/rx/pitch/ry/yaw/rz of pose1/pose2/return_pose is radian or not

    Returns:
        out (tuple[int, list]): tuple((code, pose)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        pose (list[float]): [x(mm), y(mm), z(mm), roll/rx(rad or °), pitch/ry(rad or °), yaw/rz(rad or °)]
    """
    return self.arm.get_pose_offset(pose1, pose2, orient_type_in=orient_type_in, orient_type_out=orient_type_out,
                                     is_radian=is_radian)

get_position_aa(is_radian=None)

Get the pose represented by the axis angle pose

Parameters:

Name Type Description Default
is_radian

the returned value (only rx/ry/rz) is in radians or not, default is self.default_is_radian

None

Returns:

Name Type Description
out tuple[int, list]

tuple((code, [x, y, z, rx, ry, rz])), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
950
951
952
953
954
955
956
957
958
959
960
961
962
def get_position_aa(self, is_radian=None):
    """
    Get the pose represented by the axis angle pose

    Args:
        is_radian: the returned value (only rx/ry/rz) is in radians or not, default is self.default_is_radian

    Returns:
        out (tuple[int, list]): tuple((code, [x, y, z, rx, ry, rz])), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.get_position_aa(is_radian=is_radian)

get_servo_angle(servo_id=None, is_radian=None, is_real=False)

returns the servo angle

Note
  1. if value returned should be in radians, please set is_radian to True
  2. If you want to return only the angle of a single joint, please set the parameter servo_id ex: code, angle = arm.get_servo_angle(servo_id=2)
  3. This interface is only used in the base coordinate system.

Parameters:

Name Type Description Default
servo_id

1-(Number of axes), None(8), default is None

None
is_radian

the returned value is in radians or not, default is self.default_is_radian

None

Returns:

Name Type Description

out tuple[int, float | list[float]]: tuple((code, angle list if servo_id is None or 8 else angle)), returned result is only corrent when code is 0.

code int

See the API Code Documentation for details.

angle float | list[float]

angle or list of angles depending on servo_id, unit depends on is_radian

Source code in actions\move_cartesian.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
def get_servo_angle(self, servo_id=None, is_radian=None, is_real=False):
    """
    returns the servo angle

    Note:
        1. if value returned should be in radians, please set is_radian to True
        2. If you want to return only the angle of a single joint, please set the parameter servo_id
            ex: code, angle = arm.get_servo_angle(servo_id=2)
        3. This interface is only used in the base coordinate system.

    Args:
        servo_id: 1-(Number of axes), None(8), default is None

        is_radian: the returned value is in radians or not, default is self.default_is_radian

    Returns:
        out tuple[int, float | list[float]]: tuple((code, angle list if servo_id is None or 8 else angle)), returned result is only corrent when code is 0.

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        angle (float | list[float]): angle or list of angles depending on servo_id, unit depends on is_radian
    """
    return self.arm.get_servo_angle(servo_id=servo_id, is_radian=is_radian, is_real=is_real)

get_trajectories()

Get the trajectories

Note
  1. This interface relies on xArmStudio 1.2.0 or above
  2. This interface relies on Firmware 1.2.0 or above

Returns:

Name Type Description
out tuple[int, list]

tuple((code, trajectories))

code int

See the API Code Documentation for details.

trajectories list

[{

'name'- name, The name of the trajectory

'duration'- duration, The duration of the trajectory (seconds)

}]

Source code in actions\move_cartesian.py
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
def get_trajectories(self):
    """
    Get the trajectories

    Note:
        1. This interface relies on xArmStudio 1.2.0 or above
        2. This interface relies on Firmware 1.2.0 or above

    Returns:
        out (tuple[int, list]): tuple((code, trajectories))

        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

        trajectories (list): [{

            'name'- name, The name of the trajectory

            'duration'- duration, The duration of the trajectory (seconds)

            }]
    """
    return self.arm.get_trajectories()

move_arc_lines(paths, is_radian=None, times=1, first_pause_time=0.1, repeat_pause_time=0, automatic_calibration=True, speed=None, mvacc=None, mvtime=None, wait=False)

Continuous linear motion with interpolation.

Note
  1. If an error occurs, it will return early.
  2. If the emergency_stop interface is called actively, it will return early.
  3. The last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified.
  4. The last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified.

Parameters:

Name Type Description Default
paths

cartesian path list 1. Specify arc radius: [[x, y, z, roll, pitch, yaw, radius], ....]

  1. Do not specify arc radius (radius=0): [[x, y, z, roll, pitch, yaw], ....]

  2. If you want to plan the continuous motion,set radius>0.

required
is_radian

if roll/pitch/yaw of the paths are in radians or not, default is self.default_is_radian

None
times

amount of times to repeat, 0 is infinite loop, default is 1

1
first_pause_time

sleep time at first, purpose is to cache the commands and plan continuous motion, default is 0.1s

0.1
repeat_pause_time

interval between repeated movements, unit: (s)second

0
automatic_calibration

automatic calibration or not, default is True

True
speed

move speed (mm/s, rad/s), default is self.last_used_tcp_speed

None
mvacc

move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

None
mvtime

0, reserved

None
wait

whether to wait for the arm to complete, default is False

False
Source code in actions\move_cartesian.py
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
def move_arc_lines(self, paths, is_radian=None, times=1, first_pause_time=0.1, repeat_pause_time=0,
                   automatic_calibration=True, speed=None, mvacc=None, mvtime=None, wait=False):
    """
    Continuous linear motion with interpolation.

    Note:
        1. If an error occurs, it will return early.
        2. If the emergency_stop interface is called actively, it will return early.
        3. The last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified.
        4. The last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified.

    Args:
        paths: cartesian path list
            1. Specify arc radius: [[x, y, z, roll, pitch, yaw, radius], ....]

            2. Do not specify arc radius (radius=0): [[x, y, z, roll, pitch, yaw], ....]

            3. If you want to plan the continuous motion,set radius>0.

        is_radian: if roll/pitch/yaw of the paths are in radians or not, default is self.default_is_radian

        times: amount of times to repeat, 0 is infinite loop, default is 1

        first_pause_time: sleep time at first, purpose is to cache the commands and plan continuous motion, default is 0.1s

        repeat_pause_time: interval between repeated movements, unit: (s)second

        automatic_calibration: automatic calibration or not, default is True

        speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

        mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

        mvtime: 0, reserved

        wait: whether to wait for the arm to complete, default is False
    """
    return self.arm.move_arc_lines(paths, is_radian=is_radian, times=times, first_pause_time=first_pause_time,
                                    repeat_pause_time=repeat_pause_time, automatic_calibration=automatic_calibration,
                                    speed=speed, mvacc=mvacc, mvtime=mvtime, wait=wait)

move_circle(pose1, pose2, percent, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None, is_tool_coord=False, is_axis_angle=False, **kwargs)

The motion calculates the trajectory of the space circle according to the three-point coordinates. The three-point coordinates are (current starting point, pose1, pose2).

Parameters:

Name Type Description Default
pose1

cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

required
pose2

cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

required
percent

the percentage of arc length and circumference of the movement

required
speed

move speed (mm/s, rad/s), default is self.last_used_tcp_speed

None
mvacc

move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

None
mvtime

0, reserved

None
is_radian

if roll/pitch/yaw values are in radians or not, default is self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
is_tool_coord

is tool coord or not, default is False, only available if firmware_version >= 1.11.100

False
is_axis_angle

is axis angle or not, default is False, only available if firmware_version >= 1.11.100

False
kwargs

reserved

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified

Source code in actions\move_cartesian.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
def move_circle(self, pose1, pose2, percent, speed=None, mvacc=None, mvtime=None, is_radian=None,
                wait=False, timeout=None, is_tool_coord=False, is_axis_angle=False, **kwargs):
    """
    The motion calculates the trajectory of the space circle according to the three-point coordinates.
    The three-point coordinates are (current starting point, pose1, pose2).


    Args:
        pose1: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

        pose2: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

        percent: the percentage of arc length and circumference of the movement

        speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

        mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

        mvtime: 0, reserved

        is_radian: if roll/pitch/yaw values are in radians or not, default is self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        is_tool_coord: is tool coord or not, default is False, only available if firmware_version >= 1.11.100

        is_axis_angle: is axis angle or not, default is False, only available if firmware_version >= 1.11.100

        kwargs: reserved

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

            code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified
    """
    return self.arm.move_circle(pose1, pose2, percent, speed=speed, mvacc=mvacc, mvtime=mvtime,
                                 is_radian=is_radian, wait=wait, timeout=timeout,
                                 is_tool_coord=is_tool_coord, is_axis_angle=is_axis_angle, **kwargs)

move_gohome(speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None, **kwargs)

Move to go home (Back to zero)

Warning: without limit detection

Note
  1. If you want to wait for the robot to complete it's current action and then return, set wait to True. ex: code = arm.move_gohome(wait=True)
  2. This interface does not modify the value of last_used_joint_speed/last_used_joint_acc

Parameters:

Name Type Description Default
speed

gohome speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

None
mvacc

gohome acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

None
mvtime

reserved

None
is_radian

if the speed and acceleration are in radians or not, default is self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
def move_gohome(self, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None, **kwargs):
    """
    Move to go home (Back to zero)

    Warning:
    without limit detection

    Note:
        1. If you want to wait for the robot to complete it's current action and then return, set wait to True.
            ex: code = arm.move_gohome(wait=True)
        2. This interface does not modify the value of last_used_joint_speed/last_used_joint_acc

    Args:
        speed: gohome speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

        mvacc: gohome acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

        mvtime: reserved

        is_radian: if the speed and acceleration are in radians or not, default is self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.move_gohome(speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout, **kwargs)

reset(speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None)

Reset the xArm

Warning

without limit detection

Note
  1. If there are errors or warnings, this interface will clear the warnings and errors.
  2. If not ready, the api will auto enable motion and set state
  3. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc

Parameters:

Name Type Description Default
speed

reset speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

None
mvacc

reset acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

None
mvtime

reserved

None
is_radian

if the speed and acceleration are in radians or not, defaults to self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
Source code in actions\move_cartesian.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def reset(self, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None):
    """
    Reset the xArm

    Warning:
        without limit detection

    Note:
        1. If there are errors or warnings, this interface will clear the warnings and errors.
        2. If not ready, the api will auto enable motion and set state
        3. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc

    Args:
        speed: reset speed (unit: rad/s if is_radian is True else °/s), default is 50 °/s

        mvacc: reset acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is 5000 °/s^2

        mvtime: reserved

        is_radian: if the speed and acceleration are in radians or not, defaults to self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True
    """
    return self.arm.reset(speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout)

set_cartesian_velo_continuous(on_off)

Set cartesian motion velocity continuous

Note
  1. only available if firmware_version >= 1.9.0

Parameters:

Name Type Description Default
on_off

continuous or not, True means continuous, default is False

required

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
964
965
966
967
968
969
970
971
972
973
974
975
976
977
def set_cartesian_velo_continuous(self, on_off):
    """
    Set cartesian motion velocity continuous

    Note:
        1. only available if firmware_version >= 1.9.0

    Args:
        on_off: continuous or not, True means continuous, default is False

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_cartesian_velo_continuous(on_off)

set_linear_motor_back_origin(wait=True, **kwargs)

Set the linear motor to go back to the origin position

Note
  1. only available if firmware_version >= 1.8.0
  2. only useful when powering on for the first time
  3. this operation must be performed at the first power-on

Parameters:

Name Type Description Default
wait

wait to motion finish or not, default is True

True
kwargs

auto_enable: enable after back to origin or not, default is True

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
def set_linear_motor_back_origin(self, wait=True, **kwargs):
    """
    Set the linear motor to go back to the origin position

    Note:
        1. only available if firmware_version >= 1.8.0
        2. only useful when powering on for the first time
        3. this operation must be performed at the first power-on

    Args:
        wait: wait to motion finish or not, default is True

        kwargs:
            auto_enable: enable after back to origin or not, default is True

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_linear_motor_back_origin(wait=wait, **kwargs)

set_linear_motor_enable(enable)

Set the linear motor enable/disable

Note
  1. only available if firmware_version >= 1.8.0

Parameters:

Name Type Description Default
enable

enable or not

required

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
669
670
671
672
673
674
675
676
677
678
679
680
681
682
def set_linear_motor_enable(self, enable):
    """
    Set the linear motor enable/disable

    Note:
        1. only available if firmware_version >= 1.8.0

    Args:
        enable: enable or not

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_linear_motor_enable(enable)

set_linear_motor_pos(pos, speed=None, wait=True, timeout=100, **kwargs)

Set the position of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Parameters:

Name Type Description Default
pos

position. Integer between 0 and 700/1000/1500mm.

If SN start with AL1300 the position range is 0~700mm.

If SN start with AL1301 the position range is 0~1000mm.

If SN start with AL1302 the position range is 0~1500mm.

required
speed

speed of the linear motor. Integer between 1 and 1000mm/s. default is not set

None
wait

wait to motion finish or not, default is True

True
timeout

wait timeout, seconds, default is 100s.

100

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
def set_linear_motor_pos(self, pos, speed=None, wait=True, timeout=100, **kwargs):
    """
    Set the position of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Args:
        pos: position. Integer between 0 and 700/1000/1500mm.

            If SN start with AL1300 the position range is 0~700mm.

            If SN start with AL1301 the position range is 0~1000mm.

            If SN start with AL1302 the position range is 0~1500mm.

        speed: speed of the linear motor. Integer between 1 and 1000mm/s. default is not set

        wait: wait to motion finish or not, default is True

        timeout: wait timeout, seconds, default is 100s.

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_linear_motor_pos(pos, speed=speed, wait=wait, timeout=timeout, **kwargs)

set_linear_motor_speed(speed)

Set the speed of the linear motor

Note
  1. only available if firmware_version >= 1.8.0

Parameters:

Name Type Description Default
speed

Integer between 1 and 1000mm/s.

required

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
684
685
686
687
688
689
690
691
692
693
694
695
696
697
def set_linear_motor_speed(self, speed):
    """
    Set the speed of the linear motor

    Note:
        1. only available if firmware_version >= 1.8.0

    Args:
        speed: Integer between 1 and 1000mm/s.

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_linear_motor_speed(speed)

set_linear_motor_stop()

Set the linear motor to stop

Note
  1. only available if firmware_version >= 1.8.0

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
746
747
748
749
750
751
752
753
754
755
756
def set_linear_motor_stop(self):
    """
    Set the linear motor to stop

    Note:
        1. only available if firmware_version >= 1.8.0

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_linear_motor_stop()

set_position(x=None, y=None, z=None, roll=None, pitch=None, yaw=None, radius=None, speed=None, mvacc=None, mvtime=None, relative=False, is_radian=None, wait=False, timeout=None, **kwargs)

Set the cartesian position, the API will modify self.last_used_position value

Note
  1. If it is xArm5, roll must be set to 180° or π rad, pitch must be set to 0
  2. If the parameter(roll/pitch/yaw) you are passing is an radian unit, set is_radian to True. ex: code = arm.set_position(x=300, y=0, z=200, roll=-3.14, pitch=0, yaw=0, is_radian=True)
  3. If you want to wait for the robot to complete this action and then return, set wait to True. ex: code = arm.set_position(x=300, y=0, z=200, roll=180, pitch=0, yaw=0, is_radian=False, wait=True)
  4. This interface is only used in the base coordinate system.

Parameters:

Name Type Description Default
x

cartesian position x, (mm), default is self.last_used_position[0]

None
y

cartesian position y, (mm), default is self.last_used_position[1]

None
z

cartesian position z, (mm), default is self.last_used_position[2]

None
roll

rotate around the X axis, (unit: rad if is_radian is True else °), default is self.last_used_position[3]

None
pitch

rotate around the Y axis, (unit: rad if is_radian is True else °), default is self.last_used_position[4]

None
yaw

rotate around the Z axis, (unit: rad if is_radian is True else °), default is self.last_used_position[5]

None
radius

move radius, if radius is None or radius less than 0, will MoveLine, else MoveArcLine

MoveLine: Linear motion

  • ex: code = arm.set_position(..., radius=None)

MoveArcLine: Linear arc motion with interpolation

  • ex: code = arm.set_position(..., radius=0)

  • Note: Need to set radius>=0

None
speed

move speed (mm/s, rad/s), default is self.last_used_tcp_speed

None
mvacc

move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

None
mvtime

0, reserved

None
relative

relative move or not

False
is_radian

the roll/pitch/yaw in radians or not, default is self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
kwargs

extra parameters

motion_type: motion planning type, default is 0

  • motion_type == 0: default, linear planning

  • motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

  • motion_type == 2: direct transfer to IK using joint planning

Note:

  1. only available if firmware_version >= 1.11.100

  2. when motion_type is 1 or 2, linear motion cannot be guaranteed

  3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

    speed = speed / max_tcp_speed * max_joint_speed

    mvacc = mvacc / max_tcp_acc * max_joint_acc

  4. if there is no suitable IK, a C40 error will be triggered

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

code < 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will not be modified

code >= 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified

Source code in actions\move_cartesian.py
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def set_position(self, x=None, y=None, z=None, roll=None, pitch=None, yaw=None, radius=None,
                 speed=None, mvacc=None, mvtime=None, relative=False, is_radian=None,
                 wait=False, timeout=None, **kwargs):
    """
    Set the cartesian position, the API will modify self.last_used_position value

    Note:
        1. If it is xArm5, roll must be set to 180° or π rad, pitch must be set to 0
        2. If the parameter(roll/pitch/yaw) you are passing is an radian unit, set is_radian to True.
            ex: code = arm.set_position(x=300, y=0, z=200, roll=-3.14, pitch=0, yaw=0, is_radian=True)
        3. If you want to wait for the robot to complete this action and then return, set wait to True.
            ex: code = arm.set_position(x=300, y=0, z=200, roll=180, pitch=0, yaw=0, is_radian=False, wait=True)
        4. This interface is only used in the base coordinate system.

    Args:
        x: cartesian position x, (mm), default is self.last_used_position[0]

        y: cartesian position y, (mm), default is self.last_used_position[1]

        z: cartesian position z, (mm), default is self.last_used_position[2]

        roll: rotate around the X axis, (unit: rad if is_radian is True else °), default is self.last_used_position[3]

        pitch: rotate around the Y axis, (unit: rad if is_radian is True else °), default is self.last_used_position[4]

        yaw: rotate around the Z axis, (unit: rad if is_radian is True else °), default is self.last_used_position[5]

        radius: move radius, if radius is None or radius less than 0, will MoveLine, else MoveArcLine

            MoveLine: Linear motion

            - ex: code = arm.set_position(..., radius=None)

            MoveArcLine: Linear arc motion with interpolation

            - ex: code = arm.set_position(..., radius=0)

            - Note: Need to set radius>=0

        speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

        mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

        mvtime: 0, reserved

        relative: relative move or not

        is_radian: the roll/pitch/yaw in radians or not, default is self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        kwargs: extra parameters

            motion_type: motion planning type, default is 0

            - motion_type == 0: default, linear planning

            - motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

            - motion_type == 2: direct transfer to IK using joint planning

            Note: 

            1. only available if firmware_version >= 1.11.100

            2. when motion_type is 1 or 2, linear motion cannot be guaranteed

            3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                speed = speed / max_tcp_speed * max_joint_speed

                mvacc = mvacc / max_tcp_acc * max_joint_acc

            4. if there is no suitable IK, a C40 error will be triggered

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            code < 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will not be modified

            code >= 0: the last_used_position/last_used_tcp_speed/last_used_tcp_acc will be modified
    """
    return self.arm.set_position(x=x, y=y, z=z, roll=roll, pitch=pitch, yaw=yaw, radius=radius,
                                  speed=speed, mvacc=mvacc, mvtime=mvtime, relative=relative,
                                  is_radian=is_radian, wait=wait, timeout=timeout, **kwargs)

set_position_aa(axis_angle_pose, speed=None, mvacc=None, mvtime=None, is_radian=None, is_tool_coord=False, relative=False, wait=False, timeout=None, radius=None, **kwargs)

Set the pose represented by the axis angle pose

Parameters:

Name Type Description Default
axis_angle_pose

the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

required
speed

move speed (mm/s, rad/s), default is self.last_used_tcp_speed

None
mvacc

move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

None
mvtime

0, reserved

None
is_radian

if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

None
is_tool_coord

is tool coordinate or not, if True, the relative parameter is no longer valid

False
relative

relative move or not

False
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
radius

move radius, if radius is None or radius less than 0, will MoveLineAA, else MoveArcLineAA only available if firmware_version >= 1.11.100

MoveLineAA: Linear motion

- ex: code = arm.set_position_aa(..., radius=None)

MoveArcLineAA: Linear arc motion with interpolation

- ex: code = arm.set_position_aa(..., radius=0)

- Note: Need to set radius>=0
None
kwargs

extra parameters

  • motion_type: motion planning type, default is 0

    • motion_type == 0: default, linear planning

    • motion_type == 2: direct transfer to IK using joint planning

    Note:

    1. only available if firmware_version >= 1.11.100

    2. when motion_type is 1 or 2, linear motion cannot be guaranteed

    3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

      speed = speed / max_tcp_speed * max_joint_speed

      mvacc = mvacc / max_tcp_acc * max_joint_acc

    4. if there is no suitable IK, a C40 error will be triggered

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
def set_position_aa(self, axis_angle_pose, speed=None, mvacc=None, mvtime=None,
                    is_radian=None, is_tool_coord=False, relative=False, wait=False, timeout=None, radius=None, **kwargs):
    """
    Set the pose represented by the axis angle pose

    Args:
        axis_angle_pose: the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

        speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

        mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

        mvtime: 0, reserved 

        is_radian: if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

        is_tool_coord: is tool coordinate or not, if True, the relative parameter is no longer valid

        relative: relative move or not

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        radius: move radius, if radius is None or radius less than 0, will MoveLineAA, else MoveArcLineAA
            only available if firmware_version >= 1.11.100

            MoveLineAA: Linear motion

                - ex: code = arm.set_position_aa(..., radius=None)

            MoveArcLineAA: Linear arc motion with interpolation

                - ex: code = arm.set_position_aa(..., radius=0)

                - Note: Need to set radius>=0

        kwargs: extra parameters

            - motion_type: motion planning type, default is 0

                - motion_type == 0: default, linear planning

                - motion_type == 2: direct transfer to IK using joint planning

                Note:

                1. only available if firmware_version >= 1.11.100

                2. when motion_type is 1 or 2, linear motion cannot be guaranteed

                3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                    speed = speed / max_tcp_speed * max_joint_speed

                    mvacc = mvacc / max_tcp_acc * max_joint_acc

                4. if there is no suitable IK, a C40 error will be triggered

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_position_aa(axis_angle_pose, speed=speed, mvacc=mvacc, mvtime=mvtime,
                                     is_radian=is_radian, is_tool_coord=is_tool_coord, relative=relative,
                                     wait=wait, timeout=timeout, radius=radius, **kwargs)

set_servo_angle(servo_id=None, angle=None, speed=None, mvacc=None, mvtime=None, relative=False, is_radian=None, wait=False, timeout=None, radius=None, **kwargs)

Set the servo angle, the API will modify self.last_used_angles value

Note
  1. If the parameter angle you are passing is an radian unit, be sure to set the parameter is_radian to True. ex: code = arm.set_servo_angle(servo_id=1, angle=1.57, is_radian=True)
  2. If you want to wait for the robot to complete this action and then return, please set the parameter wait to True. ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False,wait=True)
  3. This interface is only used in the base coordinate system.

Parameters:

Name Type Description Default
servo_id

1-(Number of axes), None(8)

  1. 1-(Number of axes) indicates the corresponding joint, the parameter angle should be a numeric value

    ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

  2. None(8) means all joints, default is None, the parameter angle should be a list of values whose length is the number of joints

    ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

None
angle

angle or angle list, (unit: rad if is_radian is True else °)

  1. If servo_id is 1-(Number of axes), angle should be a numeric value

    ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

  2. If servo_id is None or 8, angle should be a list of values whose length is the number of joints

    like [axis-1, axis-2, axis-3, axis-4, axis-5, axis-6, axis-7]

    ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

None
speed

move speed (unit: rad/s if is_radian is True else °/s), default is self.last_used_joint_speed

None
mvacc

move acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is self.last_used_joint_acc

None
mvtime

0, reserved

None
relative

relative move or not

False
is_radian

the angle in radians or not, default is self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
radius

move radius, if radius is None or radius less than 0, will MoveJoint, else MoveArcJoint

Note: Only available if version > 1.5.20

Note: The blending radius cannot be greater than the track length.

MoveJoint: joint motion

  • ex: code = arm.set_servo_angle(..., radius=None)

MoveArcJoint: joint fusion motion with interpolation

  • ex: code = arm.set_servo_angle(..., radius=0)

  • Note: Need to set radius>=0

None
kwargs

reserved

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details. code < 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified

code >= 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will be modified

Source code in actions\move_cartesian.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
def set_servo_angle(self, servo_id=None, angle=None, speed=None, mvacc=None, mvtime=None,
                    relative=False, is_radian=None, wait=False, timeout=None, radius=None, **kwargs):
    """
    Set the servo angle, the API will modify self.last_used_angles value

    Note:
       1. If the parameter angle you are passing is an radian unit, be sure to set the parameter is_radian to True.
            ex: code = arm.set_servo_angle(servo_id=1, angle=1.57, is_radian=True)
        2. If you want to wait for the robot to complete this action and then return, please set the parameter wait to True.
            ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False,wait=True)
        3. This interface is only used in the base coordinate system.

    Args:
        servo_id: 1-(Number of axes), None(8)

            1. 1-(Number of axes) indicates the corresponding joint, the parameter angle should be a numeric value

                ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

            2. None(8) means all joints, default is None, the parameter angle should be a list of values whose length is the number of joints

                ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

        angle: angle or angle list, (unit: rad if is_radian is True else °)

            1. If servo_id is 1-(Number of axes), angle should be a numeric value

                ex: code = arm.set_servo_angle(servo_id=1, angle=45, is_radian=False)

            2. If servo_id is None or 8, angle should be a list of values whose length is the number of joints

                like [axis-1, axis-2, axis-3, axis-4, axis-5, axis-6, axis-7]

                ex: code = arm.set_servo_angle(angle=[30, -45, 0, 0, 0, 0, 0], is_radian=False)

        speed: move speed (unit: rad/s if is_radian is True else °/s), default is self.last_used_joint_speed

        mvacc: move acceleration (unit: rad/s^2 if is_radian is True else °/s^2), default is self.last_used_joint_acc

        mvtime: 0, reserved

        relative: relative move or not

        is_radian: the angle in radians or not, default is self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        radius: move radius, if radius is None or radius less than 0, will MoveJoint, else MoveArcJoint

            Note: Only available if version > 1.5.20

            Note: The blending radius cannot be greater than the track length.

            MoveJoint: joint motion

            - ex: code = arm.set_servo_angle(..., radius=None)

            MoveArcJoint: joint fusion motion with interpolation

            - ex: code = arm.set_servo_angle(..., radius=0)

            - Note: Need to set radius>=0

        kwargs: reserved

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
            code < 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will not be modified

            code >= 0: the last_used_angles/last_used_joint_speed/last_used_joint_acc will be modified
    """
    return self.arm.set_servo_angle(servo_id=servo_id, angle=angle, speed=speed, mvacc=mvacc, mvtime=mvtime,relative=relative, is_radian=is_radian, wait=wait, timeout=timeout, radius=radius, **kwargs)

set_servo_angle_j(angles, speed=None, mvacc=None, mvtime=None, is_radian=None, **kwargs)

Set the servo angle, execute only the last instruction, need to be set to servo motion mode(self.set_mode(1))

Note
  1. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc
  2. This interface is only used in the base coordinate system.

Parameters:

Name Type Description Default
angles

angle list, (unit: rad if is_radian is True else °)

required
speed

speed, reserved

None
mvacc

acceleration, reserved

None
mvtime

0, reserved

None
is_radian

if the angles are in radians or not, default is self.default_is_radian

None
kwargs

reserved

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
def set_servo_angle_j(self, angles, speed=None, mvacc=None, mvtime=None, is_radian=None, **kwargs):
    """
    Set the servo angle, execute only the last instruction, need to be set to servo motion mode(self.set_mode(1))

    Note:
        1. This interface does not modify the value of last_used_angles/last_used_joint_speed/last_used_joint_acc
        2. This interface is only used in the base coordinate system.

    Args:
        angles: angle list, (unit: rad if is_radian is True else °)

        speed: speed, reserved

        mvacc: acceleration, reserved

        mvtime: 0, reserved

        is_radian: if the angles are in radians or not, default is self.default_is_radian

        kwargs: reserved

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_servo_angle_j(angles, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, **kwargs)

set_servo_cartesian(mvpose, speed=None, mvacc=None, mvtime=0, is_radian=None, is_tool_coord=False, **kwargs)

Set the servo to cartesian, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

Parameters:

Name Type Description Default
mvpose

cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

required
speed

move speed (mm/s), reserved

None
mvacc

move acceleration (mm/s^2), reserved

None
mvtime

0, reserved

0
is_radian

if the roll/pitch/yaw of mvpose are in radians or not, default is self.default_is_radian

None
is_tool_coord

is tool coordinate or not

False
kwargs

reserved

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
def set_servo_cartesian(self, mvpose, speed=None, mvacc=None, mvtime=0, is_radian=None, is_tool_coord=False, **kwargs):
    """
    Set the servo to cartesian, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

    Args:
        mvpose: cartesian position, [x(mm), y(mm), z(mm), roll(rad or °), pitch(rad or °), yaw(rad or °)]

        speed: move speed (mm/s), reserved

        mvacc: move acceleration (mm/s^2), reserved

        mvtime: 0, reserved

        is_radian: if the roll/pitch/yaw of mvpose are in radians or not, default is self.default_is_radian

        is_tool_coord: is tool coordinate or not

        kwargs: reserved

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_servo_cartesian(mvpose, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian,
                                         is_tool_coord=is_tool_coord, **kwargs)

set_servo_cartesian_aa(axis_angle_pose, speed=None, mvacc=None, is_radian=None, is_tool_coord=False, relative=False, **kwargs)

Set the servo cartesian represented by the axis angle pose, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

Note
  1. only available if firmware_version >= 1.4.7

Parameters:

Name Type Description Default
axis_angle_pose

the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

required
speed

move speed (mm/s), reserved

None
mvacc

move acceleration (mm/s^2), reserved

None
is_radian

if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

None
is_tool_coord

is tool coordinate or not

False
relative

relative move or not

False

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
def set_servo_cartesian_aa(self, axis_angle_pose, speed=None, mvacc=None, is_radian=None, is_tool_coord=False, relative=False, **kwargs):
    """
    Set the servo cartesian represented by the axis angle pose, execute only the last instruction, needs servo motion set to mode(self.set_mode(1))

    Note:
        1. only available if firmware_version >= 1.4.7

    Args:
        axis_angle_pose: the axis angle pose, [x(mm), y(mm), z(mm), rx(rad or °), ry(rad or °), rz(rad or °)]

        speed: move speed (mm/s), reserved

        mvacc: move acceleration (mm/s^2), reserved

        is_radian: if the rx/ry/rz of axis_angle_pose are in radians or not, default is self.default_is_radian

        is_tool_coord: is tool coordinate or not

        relative: relative move or not

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """

    return self.arm.set_servo_cartesian_aa(axis_angle_pose, speed=speed, mvacc=mvacc, is_radian=is_radian,
                                            is_tool_coord=is_tool_coord, relative=relative, **kwargs)

set_tool_position(x=0, y=0, z=0, roll=0, pitch=0, yaw=0, speed=None, mvacc=None, mvtime=None, is_radian=None, wait=False, timeout=None, radius=None, **kwargs)

Movement relative to the tool coordinate system

Note
  1. This interface is moving relative to the current tool coordinate system
  2. The tool coordinate system is not fixed and varies with position.
  3. This interface is only used in the tool coordinate system.

Parameters:

Name Type Description Default
x

the x coordinate relative to the current tool coordinate system, (unit: mm), default 0

0
y

the y coordinate relative to the current tool coordinate system, (unit: mm), default 0

0
z

the z coordinate relative to the current tool coordinate system, (unit: mm), default 0

0
roll

the rotation around the X axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

0
pitch

the rotation around the Y axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

0
yaw

the rotation around the Z axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

0
speed

move speed (mm/s, rad/s), default is self.last_used_tcp_speed

None
mvacc

move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

None
mvtime

0, reserved

None
is_radian

if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

None
wait

whether to wait for the arm to complete, default is False

False
timeout

maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

None
radius

move radius, if radius is None or radius less than 0, will MoveToolLine, else MoveToolArcLine

only available if firmware_version >= 1.11.100

MoveToolLine: Linear motion

  • ex: code = arm.set_tool_position(..., radius=None)

MoveToolArcLine: Linear arc motion with interpolation

  • ex: code = arm.set_tool_position(..., radius=0)

  • Note: Need to set radius>=0

None
kwargs

extra parameters

motion_type: motion planning type, default is 0

  • motion_type == 0: default, linear planning

  • motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

  • motion_type == 2: direct transfer to IK using joint planning

Note:

  1. only available if firmware_version >= 1.11.100

  2. when motion_type is 1 or 2, linear motion cannot be guaranteed

  3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

    speed = speed / max_tcp_speed * max_joint_speed

    mvacc = mvacc / max_tcp_acc * max_joint_acc

  4. if there is no suitable IK, a C40 error will be triggered

{}

Returns:

Name Type Description
code int

See the API Code Documentation for details.

code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified

Source code in actions\move_cartesian.py
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
def set_tool_position(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0,
                      speed=None, mvacc=None, mvtime=None, is_radian=None,
                      wait=False, timeout=None, radius=None, **kwargs):
    """
    Movement relative to the tool coordinate system

    Note:
        1. This interface is moving relative to the current tool coordinate system
        2. The tool coordinate system is not fixed and varies with position.
        3. This interface is only used in the tool coordinate system.


    Args:
        x: the x coordinate relative to the current tool coordinate system, (unit: mm), default 0

        y: the y coordinate relative to the current tool coordinate system, (unit: mm), default 0

        z: the z coordinate relative to the current tool coordinate system, (unit: mm), default 0

        roll: the rotation around the X axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

        pitch: the rotation around the Y axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

        yaw: the rotation around the Z axis relative to the current tool coordinate system, (unit: rad if is_radian is True else °), default is 0

        speed: move speed (mm/s, rad/s), default is self.last_used_tcp_speed

        mvacc: move acceleration (mm/s^2, rad/s^2), default is self.last_used_tcp_acc

        mvtime: 0, reserved

        is_radian: if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

        wait: whether to wait for the arm to complete, default is False

        timeout: maximum waiting time(unit: second), default is None(no timeout), only valid if wait is True

        radius: move radius, if radius is None or radius less than 0, will MoveToolLine, else MoveToolArcLine

            only available if firmware_version >= 1.11.100

            MoveToolLine: Linear motion

            - ex: code = arm.set_tool_position(..., radius=None)

            MoveToolArcLine: Linear arc motion with interpolation

            - ex: code = arm.set_tool_position(..., radius=0)

            - Note: Need to set radius>=0

        kwargs: extra parameters

            motion_type: motion planning type, default is 0

            - motion_type == 0: default, linear planning

            - motion_type == 1: prioritize linear planning, and turn to IK for joint planning when linear planning is not possible

            - motion_type == 2: direct transfer to IK using joint planning

            Note: 

            1. only available if firmware_version >= 1.11.100

            2. when motion_type is 1 or 2, linear motion cannot be guaranteed

            3. once IK is transferred to joint planning, the given Cartesian velocity and acceleration are converted into joint velocity and acceleration according to the percentage

                speed = speed / max_tcp_speed * max_joint_speed

                mvacc = mvacc / max_tcp_acc * max_joint_acc

            4. if there is no suitable IK, a C40 error will be triggered

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.

            code < 0: the last_used_tcp_speed/last_used_tcp_acc will not be modified

            code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified
    """
    return self.arm.set_tool_position(x=x, y=y, z=z, roll=roll, pitch=pitch, yaw=yaw, speed=speed, mvacc=mvacc, mvtime=mvtime, is_radian=is_radian, wait=wait, timeout=timeout, radius=radius, **kwargs)

set_world_offset(offset, is_radian=None, wait=True)

Set the base coordinate offset

Note
  1. This interface relies on Firmware 1.2.11 or above

Parameters:

Name Type Description Default
offset

[x, y, z, roll, pitch, yaw]

required
is_radian

if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

None
wait

whether to wait for the robotic arm to stop or all previous queue commands to be executed or cleared before setting

True

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
def set_world_offset(self, offset, is_radian=None, wait=True):
    """
    Set the base coordinate offset

    Note:
        1. This interface relies on Firmware 1.2.11 or above

    Args:
        offset: [x, y, z, roll, pitch, yaw]

        is_radian: if the roll/pitch/yaw are in radians or not, default is self.default_is_radian

        wait: whether to wait for the robotic arm to stop or all previous queue commands to be executed or cleared before setting

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.set_world_offset(offset, is_radian=is_radian, wait=wait)

vc_set_cartesian_velocity(speeds, is_radian=None, is_tool_coord=False, duration=-1, **kwargs)

Cartesian velocity control, need to be in cartesian velocity control mode(self.set_mode(5))

Note
  1. only available if firmware_version >= 1.6.9

Parameters:

Name Type Description Default
speeds

[spd_x, spd_y, spd_z, spd_rx, spd_ry, spd_rz]

required
is_radian

if the spd_rx/spd_ry/spd_rz are in radians or not, default is self.default_is_radian

None
is_tool_coord

is tool coordinate or not, default is False

False
duration

the maximum duration of the speed, over this time will automatically set the speed to 0

Note: only available if firmware_version >= 1.8.0

duration > 0: seconds, indicates the maximum number of seconds that this speed can be maintained

duration == 0: Always effective, will not stop automatically

duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

-1

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
def vc_set_cartesian_velocity(self, speeds, is_radian=None, is_tool_coord=False, duration=-1, **kwargs):
    """
    Cartesian velocity control, need to be in cartesian velocity control mode(self.set_mode(5))

    Note:
        1. only available if firmware_version >= 1.6.9

    Args:
        speeds: [spd_x, spd_y, spd_z, spd_rx, spd_ry, spd_rz]

        is_radian: if the spd_rx/spd_ry/spd_rz are in radians or not, default is self.default_is_radian

        is_tool_coord: is tool coordinate or not, default is False

        duration: the maximum duration of the speed, over this time will automatically set the speed to 0

            Note: only available if firmware_version >= 1.8.0

            duration > 0: seconds, indicates the maximum number of seconds that this speed can be maintained

            duration == 0: Always effective, will not stop automatically

            duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.vc_set_cartesian_velocity(speeds, is_radian=is_radian, is_tool_coord=is_tool_coord, duration=duration, **kwargs)

vc_set_joint_velocity(speeds, is_radian=None, is_sync=True, duration=-1, **kwargs)

Joint velocity control, need to be in joint velocity control mode(self.set_mode(4))

Note
  1. only available if firmware_version >= 1.6.9

Parameters:

Name Type Description Default
speeds

[spd_J1, spd_J2, ..., spd_J7]

required
is_radian

if the spd_Jx is in radians or not, default is self.default_is_radian

None
is_sync

whether all joints accelerate and decelerate synchronously, default is True

True
duration

The duration of this speed command, over this time will automatically set the speed to 0

Note: only available if firmware_version >= 1.8.0

duration > 0: seconds

duration == 0: Always effective, will not stop automatically

duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

-1

Returns:

Name Type Description
code int

See the API Code Documentation for details.

Source code in actions\move_cartesian.py
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
def vc_set_joint_velocity(self, speeds, is_radian=None, is_sync=True, duration=-1, **kwargs):
    """
    Joint velocity control, need to be in joint velocity control mode(self.set_mode(4))

    Note:
        1. only available if firmware_version >= 1.6.9

    Args:
        speeds: [spd_J1, spd_J2, ..., spd_J7]

        is_radian: if the spd_Jx is in radians or not, default is self.default_is_radian

        is_sync: whether all joints accelerate and decelerate synchronously, default is True

        duration: The duration of this speed command, over this time will automatically set the speed to 0

            Note: only available if firmware_version >= 1.8.0

            duration > 0: seconds

            duration == 0: Always effective, will not stop automatically

            duration < 0: default value, only used to be compatible with the old protocol, equivalent to 0

    Returns:
        code (int): See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
    """
    return self.arm.vc_set_joint_velocity(speeds, is_radian=is_radian, is_sync=is_sync, duration=duration, **kwargs)