Open
Description
When I tried to control the Lite6 gripper using set_position, I kept getting error code 19, which usually indicates unsupported command for the gripper model.
After some digging, I found the solution: instead of set_position, use the built-in commands open_lite6_gripper() and close_lite6_gripper() provided by the xArm API. Once I made the switch, everything worked perfectly.
Here’s the code with proper handling:
from xarm.wrapper import XArmAPI
import time
def control_gripper():
arm = XArmAPI('192.168.1.200')
arm.connect()
arm.clean_warn()
arm.clean_error()
try:
print("Opening gripper...")
code = arm.open_lite6_gripper()
if code != 0:
print(f"Failed to open gripper. Error code: {code}")
time.sleep(2)
print("Closing gripper...")
code = arm.close_lite6_gripper()
if code != 0:
print(f"Failed to close gripper. Error code: {code}")
time.sleep(2)
print("Stopping gripper...")
code = arm.stop_lite6_gripper()
if code != 0:
print(f"Failed to stop gripper. Error code: {code}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
arm.disconnect()
print("Disconnected from xArm.")
if name == 'main':
control_gripper()
Metadata
Metadata
Assignees
Labels
No labels