Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/sdk
13 changes: 8 additions & 5 deletions dexhand/dexhand.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, adapter_type=AdapterType.ZLG_200U, adapter_index=0):
LibDexHand.get_device_id_021s.restype = c_ubyte

LibDexHand.get_firmware_version_021s.argtypes = [c_void_p, c_ubyte]
LibDexHand.get_firmware_version_021s.restype = c_ubyte
LibDexHand.get_firmware_version_021s.restype = c_uint16

LibDexHand.enable_realtime_response_021s.argtypes = [c_void_p, c_ubyte, c_bool]

Expand All @@ -66,7 +66,10 @@ def __init__(self, adapter_type=AdapterType.ZLG_200U, adapter_index=0):
LibDexHand.move_finger_021s.argtypes = [c_void_p, c_ubyte, c_short, c_short, c_ubyte, c_uint, c_ubyte]

LibDexHand.reset_joints_021s.argtypes = [c_void_p, c_ubyte]
LibDexHand.clear_error_021s.argtypes = [c_void_p, c_ubyte, c_ubyte]
LibDexHand.clear_error_021s.argtypes = [c_void_p, c_ubyte]

LibDexHand.get_error_code_021s.argtypes = [c_void_p, c_ubyte, c_ubyte]
LibDexHand.get_error_code_021s.restype = c_ubyte

LibDexHand.get_motor_current_021s.argtypes = [c_void_p, c_ubyte, c_ubyte]
LibDexHand.get_motor_current_021s.restype = c_short
Expand Down Expand Up @@ -138,10 +141,10 @@ def reset_joints(self, device_id):
LibDexHand.reset_joints_021s(self.instance, device_id)

def get_error_code(self, device_id, finger_id):
LibDexHand.get_error_code_021s(self.instance, finger_id, device_id)
return LibDexHand.get_error_code_021s(self.instance, finger_id, device_id)
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter order in the C library call (finger_id, device_id) is inconsistent with other methods in this class, which follow the pattern (device_id, finger_id). This inconsistency could lead to incorrect API usage. Consider verifying the correct parameter order with the underlying C library and updating either this call or the argtypes declaration on line 71 to maintain consistency.

Copilot uses AI. Check for mistakes.

def clear_error(self, device_id, finger_id):
LibDexHand.clear_error_021s(self.instance, finger_id, device_id)
def clear_error(self, device_id):
LibDexHand.clear_error_021s(self.instance, device_id)

def get_motor_current(self, device_id, finger_id):
return LibDexHand.get_motor_current_021s(self.instance, finger_id, device_id)
Expand Down
15 changes: 4 additions & 11 deletions examples/DX021S_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def main():
hand021s = DexHand021S(adapter_type=AdapterType.ZLG_200U, adapter_index=0)
hand021s = DexHand021S(adapter_type=AdapterType.ZLG_MINI, adapter_index=0)
hand021s.listen(enable=True)
device_id = hand021s.get_device_id(channel=0)
# device_id = 0x01
Expand All @@ -20,10 +20,7 @@ def main():
maxCurrent1 = hand021s.get_safe_current(device_id=device_id, finger_id=0x01)
print('Maximum allowed Current of finger 1 is {}'.format(maxCurrent1))

hand021s.clear_error(device_id, 0x01)
hand021s.clear_error(device_id, 0x02)
hand021s.clear_error(device_id, 0x03)
hand021s.clear_error(device_id, 0x04)
hand021s.clear_error(device_id)

hand021s.reset_joints(device_id)
time.sleep(1)
Expand All @@ -39,19 +36,15 @@ def main():

print('joint1={}, joint2={}, joint3={}'.format(joint1, joint2, joint3))

hand021s.clear_error(device_id, 0x01)
hand021s.clear_error(device_id, 0x02)
hand021s.clear_error(device_id, 0x03)
hand021s.clear_error(device_id)

time.sleep(0.8)

hand021s.move_finger(device_id, 0x01, 0, 500, 0x55, 10)
hand021s.move_finger(device_id, 0x02, 0, 500, 0x55, 10)
hand021s.move_finger(device_id, 0x03, 0, 500, 0x55, 10)

hand021s.clear_error(device_id, 0x01)
hand021s.clear_error(device_id, 0x02)
hand021s.clear_error(device_id, 0x03)
hand021s.clear_error(device_id)

time.sleep(0.8)

Expand Down
Loading