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

How do you replicate "Align Head" from the interface #76

Closed wcdoug closed 1 year ago

wcdoug commented 1 year ago

So, in my code - I can't actually run the python code unless I first go into the UFActory app and click "Align head" - at which point the python code runs great. But I don't want to have to go into the app every time before the code starts to do this. How do I replicate the "align head" so I don't get the 111 error from the robot?

I tried clearing all errors in the code - didn't help.

vimior commented 1 year ago

@wcdoug For end leveling of the xArm5, only the angle of the fourth joint needs to be adjusted

code, angles = arm.get_servo_angle()
angles[3] = -(angles[1] + angles[2])
arm.set_servo_angle(angle=angles)
wcdoug commented 1 year ago

Thanks! That worked for me...my actual code: joint2 = arm.get_servo_angle()[1][1] joint3 = arm.get_servo_angle()[1][2] set_joint_4 = -(joint2 + joint3) arm.set_servo_angle(servo_id=4, angle=set_joint_4)