Motion
Motion commands except move_xxx_until do not wait for motion to complete. If you need to wait for motion to complete, use sync().
Start Recording Trajectory 3.1.11
Starts recording a motion trajectory.
- Function:
start_record_trajectoryfrom the lua module - Parameters:
- time: [float] Sampling period, minimum 0.01s, default 0.1s. Optional
- Returns: [bool] Whether executed successfully
Example
start_record_trajectory(0.01)
End Recording Trajectory 3.1.11
Ends recording a motion trajectory and stores it under name.
- Function:
end_record_trajectoryfrom the lua module - Parameters:
- name: [str] Trajectory name
- Returns: [bool] Whether executed successfully
Example
end_record_trajectory("test")
Replay Trajectory 3.1.11
Replays a motion trajectory with the specified name.
- Function:
move_trajectoryfrom the lua module - Parameters:
- name: [str] Trajectory name
- Returns: [int] Motion ID (motion_id), or throws error
Example
motion_id = move_trajectory("test")
Enter Teaching Mode
When the robot is in Idle state, calling this command enters teaching (free drive) mode. In teaching mode, each robot joint can be freely dragged, also known as free drive mode. End-effector payload configuration affects teaching. If the set value is larger than the actual payload, the robot will exert upward force, and vice versa. Please check carefully.
WARNING
When the robot is not in idle state, calling this command will produce error 1000: Robot must be idle to teach.
- Function:
teach_modefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
teach_mode()
Exit Teaching Mode
When the robot is in Teaching state (teaching/free drive mode), calling this command exits teaching mode and returns to Idle state. Calling in other modes does not produce an error.
- Function:
end_teach_modefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
end_teach_mode()
Pause Motion 3.1.24
Pauses all motion. Does not affect task running status.
- Function:
pause_movefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
pause_move()
Resume Motion 3.1.24
Resumes all motion. Does not affect task running status.
- Function:
resume_movefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
resume_move()
Skip Motion
Skips the current motion. This is the internal implementation mechanism of move_xxx_until series commands.
- Function:
skip_movefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
skip_move()
Stop Motion
Stops all motion, but cannot cancel subsequent newly issued motion commands.
- Function:
stop_movefrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
stop_move()
You can implement move_until functionality with the following code:
disable_auto_sync()
motion_id = movej({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.0, 0.2, 0, 0)
function wait_io()
while get_tcp_dio(1) != 1 do
wait(10)
end
stop_move()
end
task_wait_move = async_task(wait_move, motion_id)
task_wait_io = async_task(wait_io)
wait_any(task_wait_move, task_wait_io) -- Wait for any task to complete
Wait for Motion Completion 3.1.23
Waits for the specified motion to complete.
- Function:
wait_movefrom the lua module - Parameters:
- motion_id: [int] Motion ID returned by
move_xxx. Optional, default is 0, waits for all motion to complete
- motion_id: [int] Motion ID returned by
- Returns: [bool] Whether executed successfully
Example
motion_id = movej({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.0, 0.2, 0, 0)
wait_move(motion_id)
Joint Motion
Executes linear motion in joint space. Using this command, the robot must be stationary or the previous command must be movej or movel with blending.
This call returns immediately and does not wait for motion to complete. You can query status until idle via get_robot_mode, or call sync to make the robot wait synchronously until all current commands complete.
- Function:
movejfrom the lua module - Parameters:
- p: [Pose] Target position. Can be joint position
{j1 = 0.1, j2 = 0.2, j3 = 0.2, j4 = 0.3, j5 = 0.1, j6 = 0.2}or Cartesian position{x, y, z, rz, ry, rx}(converted to joint position via inverse kinematics). See Position and Orientation for details - a: [float] Main axis joint acceleration (rad/s²), max settable to maximum acceleration in safety settings
- v: [float] Main axis joint velocity (rad/s), max settable to maximum velocity in safety settings
- t: [float] Motion time (s). Optional, default 0
- When
t > 0, velocityvand accelerationaparameters are invalid.2.1 - Due to maximum acceleration and velocity in safety settings, motion time will be automatically extended
- When
- r: [float] Blending radius (m). Optional, default 0. Used to specify path smoothness
0disables smooth motion.r > 0enables smooth motion (max blending radius is 1 m), transition may not pass through target position
- p: [Pose] Target position. Can be joint position
- Returns: [int] Motion ID (motion_id), or throws error
Example
motion_id = movej({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.0, 0.2, 0, 0)
Joint Motion Until auto_sync
Executes a motion command, stops current motion when a condition is met during motion, using the move until series commands.
Compared to Joint Motion, the blending radius r is replaced with a callback function fn. The effect of this callback function is that when the motion command executes, the system calls this function once per cycle (about 10ms). If the function returns true, it automatically calls Stop Motion to stop the current motion. If the function never returns true, the robot will eventually move to p. If the function cannot complete within 10ms, it will cause skipping of subsequent cycle checks.
- Function:
movej_untilfrom the lua module - Parameters:
- p: [Pose] Target position, same as Joint Motion
- a: [float] Joint acceleration (rad/s²)
- v: [float] Joint velocity (rad/s)
- t: [float] Motion time (s). Optional, default 0
- fn: [function] Condition callback function, executed once per cycle, returns
trueto stop current motion
- Returns: [bool] Whether executed successfully
Example
In Lua syntax, functions can be anonymous.
movej_until({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.2, 0.2, 0, function()
return get_aio(2) > 10
end)
Linear Motion
Executes linear motion path in tool space. Using this command, the robot must be stationary or the previous command must be movej or movel with blending.
- Function:
movelfrom the lua module - Parameters:
- p: [Pose] Target position. Can be Cartesian position
{x, y, z, rz, ry, rx}or joint position (converted to Cartesian position via forward kinematics) - a: [float] Tool space acceleration (m/s²)
- v: [float] Tool space velocity (m/s). Note that velocity and acceleration here refer to tool space description
- t: [float] Motion time (s). Optional, default 0
- r: [float] Blending radius (m). Optional, default 0
- p: [Pose] Target position. Can be Cartesian position
- Returns: [int] Motion ID (motion_id), or throws error
WARNING
Abnormalities occur near singular positions and workspace boundaries. Use Joint Motion instead.
Example
movel({0.2, 0.5, 0.4, 0, 0, 1.57}, 1.0, 0.2, 0, 0)
movel({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.0, 0.2, 0, 0)
Linear Motion Until auto_sync
Executes linear motion path in tool space, stops when a specified condition is met.
Refer to Linear Motion and Joint Motion Until descriptions.
- Function:
movel_untilfrom the lua module - Parameters:
- p: [Pose] Target position, same as Linear Motion
- a: [float] Tool space acceleration (m/s²)
- v: [float] Tool space velocity (m/s)
- t: [float] Motion time (s). Optional, default 0
- fn: [function] Condition callback function, executed once per cycle, returns
trueto stop current motion
- Returns: [bool] Whether executed successfully
Example
movel_until({0.2, 0.5, 0.4, 0, 0, 1.57}, 1.0, 0.2, 0, function()
return get_tcp_dio(1) == 0
end)
Hybrid Motion
Linear motion. Unlike movel, when encountering a singular position, it automatically switches to joint motion.
- Function:
move_hybridfrom the lua module - Parameters:
- p: [Pose] Target position. Can be Cartesian position or joint position (converted via forward kinematics)
- a: [float] Tool space acceleration (m/s²)
- v: [float] Tool space velocity (m/s). Note that velocity and acceleration here refer to tool space description
- t: [float] Motion time (s). Optional, default 0
- r: [float] Blending radius (m). Optional, default 0
- Returns: [int] Motion ID (motion_id), or throws error
Example
move_hybrid({0.2, 0.5, 0.4, 0, 0, 1.57}, 1.0, 0.2, 0, 0)
move_hybrid({j1 = 0, j2 = 1.57, j3 = -1.57, j4 = 0, j5 = 3.14, j6 = 3.14}, 1.0, 0.2, 0, 0)
Circular Motion
Performs circular motion in tool space. The path is the unique circle formed by the current position, via, and p. If the three points are collinear and cannot form a circle, or the distances between points are too small resulting in a circle that is too large or too small, the command will fail. The robot orientation after completing circular motion is consistent with p, independent of rad.
- Function:
movecfrom the lua module - Parameters:
- via: [Pose] Waypoint. Can be Cartesian position or joint position (converted to Cartesian position)
- p: [Pose] Target position. Can be Cartesian position or joint position (converted to Cartesian position)
- rad: [float] Path arc radians (rad). Used to specify the arc size of circular motion
- Specially and by default, when
rad = 0, it means moving topas the endpoint. - If
rad > 0, it means following a circular motion trajectory passing throughviaandp, rotating by the correspondingrad. - If
rad < 0, it means following circular motion trajectory in the opposite direction,viaandpmay not be passed in this mode.
- Specially and by default, when
- a: [float] Tool space acceleration (m/s²)
- v: [float] Tool space velocity (m/s)
- t: [float] Motion time (s). Optional, default 0
- r: [float] Blending radius (m). Optional, default 0
- Returns: [int] Motion ID (motion_id), or throws error
Example
movec({0.2, 0.5, 0.4, 0, 0, 1.57}, {j1 = 0.1, j2 = 0.2, j3 = 0.2, j4 = 0.3, j5 = 0.1, j6 = 0.2}, 0.0, 1.0, 0.2, 0)
Circular Motion Until auto_sync
Performs circular motion in tool space, stops when a specified condition is met.
Refer to Circular Motion and Joint Motion Until descriptions.
- Function:
movec_untilfrom the lua module - Parameters:
- via: [Pose] Waypoint, same as Circular Motion
- p: [Pose] Target position, same as Circular Motion
- rad: [float] Path arc radians (rad)
- a: [float] Tool space acceleration (m/s²)
- v: [float] Tool space velocity (m/s)
- t: [float] Motion time (s). Optional, default 0
- fn: [function] Condition callback function, executed once per cycle, returns
trueto stop current motion
- Returns: [bool] Whether executed successfully
Example
movec_until({0.2, 0.5, 0.4, 0, 0, 1.57}, {j1 = 0.1, j2 = 0.2, j3 = 0.2, j4 = 0.3, j5 = 0.1, j6 = 0.2}, 0.0, 1.0, 0.2, 0, function()
return get_tcp_dio(1) == 0
end)
Servo Motion (PVAT) 2.3.5
Specifies velocity and acceleration for each joint, allowing the robot to perform continuous servo motion.
WARNING
- The minimum settable time is 0.01 (10ms). Path points below this value will be skipped.
- The sending interval between 2 adjacent points must be less than
t. Exceedingtwill cause the robot to automatically decelerate and stop.
- Function:
move_pvatfrom the lua module - Parameters:
- Returns: [bool] Whether executed successfully
Example
move_pvat({j1=0.279099, j2=0.0499054, j3=0.320451, j4=0.172128, j5=1.67471, j6=0.427222}, {0.00141239, 0.017133, 0.015709, 0.0477418, 0.0037477, 0.0504095}, 0, 0.01)
move_pvat({-0.490491, -0.257047, -0.0192966, -1.60649, -0.311108, 2.14048}, 0.1, 0, 0.01)
Servo Motion (PVT) 2.3.5
Same as Servo Motion (PVAT), with the robot automatically estimating each joint's acceleration.
- Function:
move_pvtfrom the lua module - Parameters:
- Returns: [bool] Whether executed successfully
Example
move_pvt({j1=0.279099, j2=0.0499054, j3=0.320451, j4=0.172128, j5=1.67471, j6=0.427222}, {0.00141239, 0.017133, 0.015709, 0.0477418, 0.0037477, 0.0504095}, 0.01)
move_pvt({-0.490491, -0.257047, -0.0192966, -1.60649, -0.311108, 2.14048}, 0.1, 0.01)
Servo Motion (PT) 2.3.5
Same as Servo Motion (PVAT), with the robot automatically estimating each joint's velocity and acceleration.
- Function:
move_ptfrom the lua module - Parameters:
- p: [JointPose] Joint position
- t: [float] Motion time (s)
- Returns: [bool] Whether executed successfully
Example
move_pt({j1=0.279099, j2=0.0499054, j3=0.320451, j4=0.172128, j5=1.67471, j6=0.427222}, 0.01)
Reset Joint Laps
Resets the cumulative lap count for each joint.
- Function:
reset_joint_lapsfrom the lua module - Parameters: none
- Returns: [bool] Whether executed successfully
Example
reset_joint_laps()
Example
local v = 0.06
local a = 0.1
function draw_star(base, r)
movej(base, 0.4, 1, 0, 1)
local b = pose_times(base, {-r * math.sin(math.rad(18)), -r * math.cos(math.rad(18)), 0, 0, 0, 0})
movel(b, v, a, 0, 0)
local c = pose_times(base, {r / 2, -r / 2 * math.cos(math.rad(36)), 0 , 0, 0, 0})
movel(c, v, a, 0, 0)
local d = pose_times(base, {-r / 2, -r / 2 * math.cos(math.rad(36)), 0, 0, 0, 0})
movel(d, v, a, 0, 0)
local e = pose_times(base, {r * math.sin(math.rad(18)), -r * math.cos(math.rad(18)), 0, 0, 0, 0})
movel(e, v, a, 0, 0)
movel(base, v, a, 0, 0)
sync()
end
local base = get_actual_tcp_pose()
draw_star(base, 0.1)
