diff --git a/config/l1_hand.json b/config/l1_hand.json index d13f510..a832381 100644 --- a/config/l1_hand.json +++ b/config/l1_hand.json @@ -1,13 +1,7 @@ { "model": "L1-Hand-V1", - "name": "L1-Hand-V1", - "aliases": ["XiaoShun-Hand"], - "slave_id": 49, + "name": "GHand Lite 1", "modbus_profile": "l1", - "ethercat_input_sizes": [1302], - "ethercat_output_size": 36, - "ethercat_rpdo_layout": "per_joint_mode_3reg", - "ethercat_tpdo_layout": "l1_extended", "joints": [ { "id": "THUMB_TMC_FE" }, { "id": "THUMB_TMC_AA", "min": 0.0, "max": 30.0 }, @@ -21,6 +15,12 @@ { "id": "LF_PIP" }, { "id": "LF_MCP", "min": 0.0, "max": 90.0 } ], - "has_tactile": false, - "tactile_regions": [] + "has_tactile": true, + "tactile_regions": [ + { "id": "THUMB", "count": 80 }, + { "id": "FF", "count": 80 }, + { "id": "MF", "count": 80 }, + { "id": "RF", "count": 80 }, + { "id": "LF", "count": 80 } + ] } diff --git a/src/ghand/_config.py b/src/ghand/_config.py index f22d621..677c13b 100644 --- a/src/ghand/_config.py +++ b/src/ghand/_config.py @@ -254,7 +254,11 @@ def find_config_by_name(device_name: str) -> ProductConfig | None: except (json.JSONDecodeError, OSError): continue - names = [data.get("name", ""), *data.get("aliases", [])] + names = [ + data.get("model", ""), + data.get("name", ""), + *data.get("aliases", []), + ] if any(name.lower() == device_name.lower() for name in names if name): logger.info("Auto-detected product config: %s -> %s", device_name, file_path) return _load_config_from_file(file_path) diff --git a/tests/test_connection_cleanup.py b/tests/test_connection_cleanup.py index 09115e8..58e8874 100644 --- a/tests/test_connection_cleanup.py +++ b/tests/test_connection_cleanup.py @@ -1,3 +1,5 @@ +import math +import struct import sys import types from pathlib import Path @@ -338,14 +340,14 @@ def test_ethercat_comm_keeps_default_708_tpdo_layout(): assert [region.count for region in comm.config.tactile_regions] == [52, 31, 31, 31, 31] -def test_ethercat_l1_accepts_extended_pdo_sizes_and_packs_per_joint_commands(): +def test_ethercat_l1_uses_configured_tactile_pdo_sizes_and_default_rpdo(): config = load_product_config(ProductType.L1) comm = EthercatComm.__new__(EthercatComm) comm._client = FakeEthercatClientForSend() comm.update_config(config) - assert comm._expected_tpdo_sizes == (92, 1302) - assert comm._expected_rpdo_size == 36 + assert comm._expected_tpdo_sizes == (1168, 1324) + assert comm._expected_rpdo_size == 38 comm.move_joints( [JointCommand(id=JointId.FF_MCP, angle=12.3, speed=-4, torque=5)], @@ -353,24 +355,29 @@ def test_ethercat_l1_accepts_extended_pdo_sizes_and_packs_per_joint_commands(): ) data = comm._client.sent[-1] - assert len(data) == 36 - assert data[0:6] == bytes.fromhex("02 00 00 00 00 00") - assert data[12:18] == bytes.fromhex("02 00 7b 00 fc 05") + assert len(data) == 38 + assert data[0:2] == bytes.fromhex("02 00") + angle, speed, torque = struct.unpack_from("