Skip to content

Facing Error 19 While Using set_position with Xarm gripper? #135

Open
@Shrav211

Description

@Shrav211

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions