2. Linear motion

1. Linear Motion

Initialization

Assume the robotic arm controller's IP address is 192.168.1.47, initialize the robotic arm.

from xarm.wrapper import XArmAPI  
arm=XArmAPI('192.168.1.47')

Enable

If the robotic arm is not enabled, it needs to be enabled. Once enabled, there is no need to enable it again.

arm.motion_enable(enable=True)

Set Mode and State

After enabling, you need to set the mode and state for the robotic arm to move. The robotic arm has multiple modes; the commonly used linear motion and joint motion are both position commands, i.e., mode 0.

arm.set_mode(0)

The robotic arm can be set to various modes. Mode 0 is for motion, mode 3 is for pausing the motion, and mode 4 is for stopping the motion.

arm.set_state(0)

Send Position Command

In the xArm-Python-SDK, the Cartesian position is defined as x, y, z, roll, pitch, yaw. The unit for distance is millimeters (mm), and the default angle representation is degrees (°).

As an example of linear motion in Cartesian space, let the robotic arm move to point A [300,0,150,180,0,0] first, and then to point B [400,0,150,180,0,0].

arm.set_position(300,0,150,180,0,0)  
arm.set_position(400,0,150,180,0,0)

Speed

In the set_position() interface for linear motion, the speed is passed with the speed parameter, and the unit is mm/s. For example, let the robotic arm move to point A [300,100,150,180,0,0] at 200 mm/s.

arm.set_position(300,100,150,180,0,0, speed=200)

Complete Example

from xarm.wrapper import XArmAPI  
arm = XArmAPI('192.168.1.47')  
arm.motion_enable(enable=True)  
arm.set_mode(0)  
arm.set_state(0)  
  
arm.set_position(300,0,150,180,0,0, speed=200)  
arm.set_position(400,0,150,180,0,0, speed=200)

Last updated