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}, Type: {dev.device_type}, Address: {dev.address}")Scans for Wuji devices connected via Ethernet on the local network. The returned DiscoveredDevice contains the serial number, address, and device type. device_type is a DeviceType enum (WujiGlove / WujiHand2 / WujiHand), so you can tell what a device is before connecting. Unknown means the type was not available at scan time or isn't recognized by this SDK build.
Wuji Hand 2 network prerequisite: the device uses a static IP, not DHCP—left hand 192.168.1.110, right hand 192.168.1.111. Before scanning or connecting, set your host NIC to the same subnet (for example 192.168.1.100), or the device can't be discovered or reached. See the Wuji Hand 2 SDK reference for address details and how to change the IP.
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() — it reflects the current attachment and turns False after the glove is unplugged at runtime. Once unplugged, the tactile status stream's state becomes 0 (not present), other tactile reads and subscriptions fail with a tactile_not_present error, and the hand itself keeps working. Re-attaching the glove requires reconnecting the hand.
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
)enable_bridge (default True) controls whether multiple SDK instances (including processes on other hosts) can connect to the same device. When enabled, this process shares the connected device. Set it to False for exclusive access — other instances can't reach the device through this process.
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")Use different device_name values to keep the left and right hand in the same process. Reconnecting to an already-active device raises SessionAlreadyExists without dropping the existing connection — keep using the existing handle.
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.