Skip to main content

Application Architecture

The HausBots Robot Control application is a high-performance React Native mobile app designed to provide low-latency control and real-time visualization for crawler robots.

Tech Stack

  • Framework: React Native (TypeScript)
  • Communication: roslib (WebSocket bridge to ROS)
  • Styling: React Native StyleSheet (Standard UI components)
  • Hardware Integration: Custom hooks for USB-HID (Joystick) support.
  • Performance: react-native-reanimated and react-native-worklets for off-main-thread processing.

Project Structure

Screens (src/screens/)

  • Launch: The entry point where the user selects the robot ID and basic configuration.
  • Connection: Manages the WebSocket handshake and displays the connection status of various subsystems.
  • Control: The primary operating dashboard, integrating the camera feed, joystick inputs, telemetry, and PTZ camera controls.
  • Debug: A low-level view of incoming ROS messages and raw sensor data.

Core Utilities (src/utils/)

  • ros.tsx: The central ROS manager. It initializes the Ros connection and manages all Publishers and Subscribers. To handle high-frequency control messages (up to 100Hz+), it utilizes useFrameCallback from Reanimated and scheduleOnRN from Worklets. This ensures that the /pat/control/pat_cmd topic is published consistently without blocking the main UI thread.

Hardware Hooks (src/hooks/)

  • useUsbHidController.ts: Listens for physical gamepads connected via USB or Bluetooth. It maps raw HID events to the PatJoyControl message structure.

Communication Pattern

The app uses a Publish-Subscribe model via rosbridge:

  1. Input Sensing: A Joystick component or the useUsbHidController hook captures user intent.
  2. Message Transformation: Intent is converted into a standard ROS message (e.g., throttle and steering values).
  3. High-Frequency Publishing: Control commands are published via a worklet-driven loop, allowing for stable rates exceeding 100Hz while keeping the UI responsive.
  1. Camera Control: The Control screen manages PTZ (Pan-Tilt-Zoom) and lighting commands for the IP camera, publishing updates to the /pat/camera/control topic based on gamepad or UI interactions.
  2. UI Feedback: Telemetry subscribers (e.g., liveDataTopic) update the React state, triggering re-renders of the telemetry dashboard.

Video Pipeline

The video system bypasses the robot computer for maximum performance and reliability. An IP camera is connected directly to an onboard ethernet switch, which also connects the robot and the Android tablet. The app retrieves the RTSP video feed directly from the camera's IP address. This stream is displayed using the RtspVideoView component, which utilizes native hardware acceleration to minimize latency.

State Management

Global robot state (connection status, battery levels, motor errors) is managed through custom React hooks. Critical updates (like a motor failure) trigger high-priority UI warnings to ensure operator safety.