Skip to content

Add Device Connection Status and Device ID Information to Python Bindings #5

@zhangjunhui6

Description

@zhangjunhui6

Feature Request: Device Connection Status and Device ID Support

Background

Currently, the XRoboToolkit Python bindings provide excellent access to pose data, controller inputs, hand tracking, and body tracking. However, there's no way to programmatically check device connection status or retrieve device identification information, which is crucial for robust applications.

Requested Features

  1. Device Connection Status
# Proposed API
import xrobotoolkit_sdk as xrt

xrt.init()

# Check overall connection status
is_connected = xrt.is_device_connected()
print(f"Device connected: {is_connected}")

# Check specific data valid
headset_data_valid = xrt.is_headset_data_available()
controller_data_valid = xrt.is_controller_data_available()
  1. Device Information
device_id = xrt.get_device_id()
  1. Connection Events (Optional)
# Callback for connection state changes
def on_device_connected(device_type, device_id):
    print(f"Device {device_type} ({device_id}) connected")

def on_device_disconnected(device_type, device_id):
    print(f"Device {device_type} ({device_id}) disconnected")

xrt.set_connection_callback(on_device_connected, on_device_disconnected)

Use Cases

  1. Robust Application Development : Applications can gracefully handle device disconnections and reconnections
  2. Debugging and Monitoring : Easier troubleshooting of connection issues
  3. Battery Monitoring : Alert users when device batteries are low

Implementation Suggestions

Based on the current codebase structure, these functions could be added to the existing pybind11 interface by:

  1. Extending the current m.def() calls in the binding code
  2. Adding corresponding C++ functions that interface with the PXREARobot SDK
  3. Utilizing existing SDK functions like PXREAGetDeviceState() if available

Benefits

  • Improved Reliability : Applications can detect and handle connection issues
  • Better User Experience : Clear feedback about device status
  • Enhanced Debugging : Easier identification of hardware-related issues
  • Professional Applications : Essential for production robotics and telepresence systems

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions