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-reanimatedandreact-native-workletsfor 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
Rosconnection and manages all Publishers and Subscribers. To handle high-frequency control messages (up to 100Hz+), it utilizesuseFrameCallbackfrom Reanimated andscheduleOnRNfrom Worklets. This ensures that the/pat/control/pat_cmdtopic 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
PatJoyControlmessage structure.
Communication Pattern
The app uses a Publish-Subscribe model via rosbridge:
- Input Sensing: A
Joystickcomponent or theuseUsbHidControllerhook captures user intent. - Message Transformation: Intent is converted into a standard ROS message (e.g.,
throttleandsteeringvalues). - High-Frequency Publishing: Control commands are published via a worklet-driven loop, allowing for stable rates exceeding 100Hz while keeping the UI responsive.
- Camera Control: The
Controlscreen manages PTZ (Pan-Tilt-Zoom) and lighting commands for the IP camera, publishing updates to the/pat/camera/controltopic based on gamepad or UI interactions. - 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.