xArm-Developer / xArm-Python-SDK

Python SDK for UFACTORY robots, 850, xArm5/6/7, and Lite6.
https://www.ufactory.cc
BSD 3-Clause "New" or "Revised" License
180 stars 112 forks source link

ServoJ speed limit errors #94

Open colin-r-schultz opened 1 year ago

colin-r-schultz commented 1 year ago

While using SevoJ mode, we frequently encounter C24 speed limit errors. We believe these occur when the TCP exceeds 1000mm/s. This response to #88 suggests that the TCP speed limit should only apply to cartesian motions, not ServoJ. The speed limit does not apply in position control mode, online planning mode, or velocity control mode. Could you please confirm the intended behavior?

penglongxiang commented 1 year ago

Hi, in the answer from #88 the Cartesian speed limit is not applicable for Joint motion in mode 0, of which the trajectory is planned by our internal controller. Since Servo Mode is special, if the command from user is not well interpolated, the execution may not be safe, so we still added the Cartesian speed check under Servo Mode, would you please download the log immediately after you reproduce the overspeed error in servoJ operation for us to diagnose? Thank you.

colin-r-schultz commented 1 year ago

XI130308B22L24_2023-09-08_10-26-45.tar.gz

I can replicate the speed error with the following script:

import time
import numpy as np
from xarm.wrapper import XArmAPI

SPEED = 2.0  # rad/s

start = np.deg2rad([-90, 27, -69, 0, 41, 3.7])
api = XArmAPI("192.168.250.232", is_radian=True)
print("enabling")
api.motion_enable(enable=True)
time.sleep(1)
print("setting mode 0")
api.set_mode(0)
api.set_state(0)
time.sleep(1)
api.set_servo_angle(angle=start, wait=True)

# set servo j control mode
print("setting mode 1")
api.set_mode(1)
api.set_state(0)
time.sleep(1)
_, init_joints = api.get_servo_angle()
_, pos = api.get_position()
radius = np.linalg.norm(pos[0:2])  # radius in xy plane
print("radius:", radius)

start_t = time.perf_counter()
while (t := time.perf_counter() - start_t) < 0.8:
    pos = init_joints.copy()
    pos[0] += SPEED * t
    api.set_servo_angle_j(pos)
    time.sleep(0.005)

We put the end effector at around 550mm from the base, then move joint 0 at 2 rad/s to surpass the speed of 1000mm/s. It is strange that this motion is allowed using mode 0, mode 4 or mode 6.

penglongxiang commented 1 year ago

Thanks for the log and script, indeed the C24 error occurs because of the command linear velocity exceeds 1000mm/s at your start configuration. As 550mm * 2 rad/s = 1100 mm/s. And this restriction applies in Mode 1 because of the safety consideration as I mentioned in previous reply, the trajectory is not generated by our algorithm and we would force a linear speed limit to this mode even for joint motion. We will re-evaluate this logic in the future to see if there is a better option or design.

MinnaZhong commented 7 months ago

Hey guys,

We added a new parameter to solve this problem, the user now can specify their own TCP speed limit for servoJ mode.

  1. The firmware and ufactoryStudio version should be ≥2.3.0. For your reference: https://docs.ufactory.cc/support_articles/faq/how-to-update-the-firmware-and-ufactory-studio-of-robotic-arm
  2. Please use set_linear_spd_limit_factor to set your TCP speed limits for servoJ mode. factor×1000 = linear speed limit, the default value is 1.2×1000=1200mm/s If you want this setting to take effect even after restarting the arm, please call save_conf() to save this config. image