JeanElsner / panda-py

Python bindings for real-time control of Franka Emika robots.
https://jeanelsner.github.io/panda-py/
Apache License 2.0
77 stars 14 forks source link

Move command aborted: motion aborted by reflex! ["controller_torque_discontinuity"] #2

Closed LJY-XCX closed 10 months ago

LJY-XCX commented 11 months ago

Hi! I want to use panda-py to execute a sequence of gripper pose on fr3. But I find that sometimes the move_to_pose function does not work, especially when the gripper deviates from the starting position. Can you help me with that? Here is the error: Control loop interruped: libfranka: Move command aborted: motion aborted by reflex! ["controller_torque_discontinuity"] control_command_success_rate: 1 Irregular state detected. Attempting automatic error recovery. Segmentation fault (core dumped)

JeanElsner commented 11 months ago

Thank you very much for this report! I haven't personally encountered this error yet. However, I also don't have currently access to the Franka Research 3, only the older Panda models. What I can do, is to try smooth the torques. Can you additionally provide me with an example code, that often leads to this error?

LJY-XCX commented 11 months ago

Thank you for the help! Here is my code for trajectory mimicing and this is where the error raises:

trans_list and rot_list are 3x1 numpy array stored lists whose elements represent translations and Euler rotations,

accumulated_trans = np.zeros(3) accumulated_rot = np.zeros(3)

for i in range(len(trans_list) - 1): delta_trans = trans_list[i+1] - trans_list[i] delta_rot = rot_list[i+1] - rot_list[i]

  # Accumulate the delta values
  accumulated_trans += delta_trans
  accumulated_rot += delta_rot

  # Check if accumulated values meet the thresholds
  if (np.max(accumulated_trans) >= 0.1 and np.max(accumulated_rot) >= 0.05) or i == len(trans_list) - 2:
      T_1 = SE3.Trans(accumulated_trans[0], accumulated_trans[1], accumulated_trans[2]) * T_0 * SE3.Rx(accumulated_rot[0]) * SE3.Ry(accumulated_rot[1]) * SE3.Rz(accumulated_rot[2])
      poses.append(T_1)
      T_0 = T_1
      # Reset the accumulated values
      accumulated_trans = np.zeros(3)
      accumulated_rot = np.zeros(3)

  if np.max(accumulated_trans) >= 0.1 and i != len(trans_list) - 2:
    T_1 = SE3.Trans(accumulated_trans[0], accumulated_trans[1], accumulated_trans[2]) * T_0
    poses.append(T_1)
    T_0 = T_1
    accumulated_trans = np.zeros(3)

  if np.max(accumulated_rot) >= 0.05 and i != len(trans_list) - 2:
    T_1 = T_0 * SE3.Rx(accumulated_rot[0]) * SE3.Ry(accumulated_rot[1]) * SE3.Rz(accumulated_rot[2])
    poses.append(T_1)
    T_0 = T_1
    accumulated_rot = np.zeros(3)

qs_list = [] for pose in poses: qs_list.append(panda_py.ik(pose))

for i in range(len(qs_list)): print('step:', i) panda.move_to_joint_position(qs_list[i], speed_factor=0.1, stiffness=stiffness, success_threshold=0.01)

print('trajectory length:', len(poses))

JeanElsner commented 10 months ago

I don't see anything wrong with your code. The new version 0.6.1 includes torque saturation, this may help avoid the torque discontinuity. Could you try with this new release? If that doesn't help, maybe you can send me a trajectory (or list of poses) that triggers this error for you.

LJY-XCX commented 10 months ago

Thanks a lot! I will try it later!