Device Discovery & Connection
Device Discovery
Use SdkManager.scan() to discover Wuji devices on the local network:
from wuji_sdk import SdkManager
manager = SdkManager.instance()
devices = manager.scan()
for dev in devices:
print(f"SN: {dev.sn}, Address: {dev.address}")Scans for Wuji devices connected via Ethernet on the local network. The returned DiscoveredDevice contains the device serial number and address.
Connecting to a Device
device_name in all connect APIs is a local alias, used only to look up the device later and to namespace resource paths. It does not select a device and does not determine the returned handle type. The returned type is determined by the actual connected device. The name must be non-empty and must not contain / or ..
Auto Connect
auto_connect() connects to the single device currently discovered. If multiple devices are present, the call fails because the target is ambiguous. Use connect() to disambiguate in that case:
glove = manager.auto_connect(device_name="glove")
print(f"Connected: {glove.serial_number}")Connect by SN
Connect to a specific device by serial number:
glove = manager.connect(sn="WG1JA00XXXXXXXXX", device_name="glove")Connect by Address
Manually connect using IP address and port:
glove = manager.connect(address="192.168.1.100:50000", device_name="glove")Connect by USB
Wuji Hand attaches over USB. Filter SdkManager.scan() by TransportType.Usb:
from wuji_sdk import SdkManager, TransportType
manager = SdkManager.instance()
usb_devices = [d for d in manager.scan() if d.transport_type == TransportType.Usb]
hand = manager.connect(sn=usb_devices[0].sn, device_name="wuji_hand")
print(f"Connected: {hand.serial_number} ({hand.handedness_name()})")If a matching-handedness tactile glove is plugged in alongside the hand, the SDK auto-pairs it on connect. Check with hand.is_tactile_attached().
Connect by Handedness
Connect to a two-handed device (such as Wuji Hand 2 or Wuji Glove) by left or right hand, without looking up a serial number first. The SDK scans the local network and selects the unique device by the fourth character of its serial number (J for left, K for right):
from wuji_sdk import Handedness
# Connect the right-hand device
hand = manager.connect(handedness=Handedness.Right, device_name="wuji_hand_2")
# Connect the left-hand glove
glove = manager.connect(handedness=Handedness.Left, device_name="wuji_glove")handedness is mutually exclusive with sn and address—specify only one.
If no device matches the handedness, DeviceNotFound is raised. If multiple devices share the handedness, AmbiguousHandedness is raised with all candidate serial numbers. Specify sn explicitly instead.
Connection Options
Configure connection parameters with ConnectOptions:
from wuji_sdk import ConnectOptions
options = ConnectOptions(
timeout_ms=1000, # Connection timeout (milliseconds)
retry_count=3 # Number of retries
)
glove = manager.connect(
sn="WG1JA00XXXXXXXXX",
device_name="glove",
options=options
)Multi-device Management
The SDK supports connecting multiple devices simultaneously, each identified by a unique device_name:
left = manager.connect(handedness=Handedness.Left, device_name="left_hand")
right = manager.connect(handedness=Handedness.Right, device_name="right_hand")
# Get all connected devices
all_devices = manager.get_connected_devices()
for name, device in all_devices:
print(f"{name}: {device.serial_number}")
# Get a device by name
left = manager.get_device(device_name="left_hand")Disconnecting
# Disconnect a specific device
manager.disconnect(device_name="glove")
# Or disconnect via the device object
glove.disconnect()When a device is disconnected, all subscriptions on that device are automatically closed. You'll need to re-establish subscriptions after reconnecting.