Skip to content

Commit 1e88865

Browse files
committed
fix validates the adapter/hardware-type pairing upfront with a clear error
1 parent e702074 commit 1e88865

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

dimos/control/coordinator.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,23 @@ def add_hardware(
341341
component: HardwareComponent,
342342
) -> bool:
343343
"""Register a hardware adapter with the coordinator."""
344+
from dimos.hardware.drive_trains.spec import TwistBaseAdapter as TwistBaseAdapterProto
345+
346+
is_base = component.hardware_type == HardwareType.BASE
347+
is_twist_adapter = isinstance(adapter, TwistBaseAdapterProto)
348+
if is_base != is_twist_adapter:
349+
raise TypeError(
350+
f"Hardware type / adapter mismatch for '{component.hardware_id}': "
351+
f"hardware_type={component.hardware_type.value} but adapter is "
352+
f"{'TwistBaseAdapter' if is_twist_adapter else 'ManipulatorAdapter'}"
353+
)
354+
344355
with self._hardware_lock:
345356
if component.hardware_id in self._hardware:
346357
logger.warning(f"Hardware {component.hardware_id} already registered")
347358
return False
348359

349-
if component.hardware_type == HardwareType.BASE:
360+
if is_base:
350361
connected: ConnectedHardware = ConnectedTwistBase(
351362
adapter=adapter, # type: ignore[arg-type]
352363
component=component,

0 commit comments

Comments
 (0)