-
Notifications
You must be signed in to change notification settings - Fork 0
Robot Controller UI
Shushi Huang edited this page Jul 5, 2025
·
2 revisions
A Next.js-based web interface for controlling and monitoring the McGill Robotics rover. This application provides real-time control capabilities for the rover's drive system, robotic arm, and camera feeds through an intuitive web interface.
This is a Next.js 15 application built with TypeScript, Tailwind CSS, and React 19. The UI communicates with backend services through WebRTC for camera streams and WebSocket/HTTP APIs for robot control.
- Frontend: Next.js 15, React 19, TypeScript
- Styling: Tailwind CSS 4
- Charts: Recharts
- Icons: Lucide React
- HTTP Client: Axios
- Real-time Communication: WebRTC, WebSockets
src/
├── app/ # Next.js App Router pages
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout with navbar
│ ├── page.tsx # Home page (redirects to /status)
│ ├── arm/ # Arm control page
│ ├── drive/ # Drive control page
│ └── status/ # System status page
│
├── components/ # Reusable UI components
│ ├── icons/ # Custom icon components
│ ├── layout/ # Layout components (navbar, etc.)
│ ├── sections/ # Page-specific component sections
│ │ ├── arm/ # Arm-related components
│ │ │ ├── control/ # Arm control interface & PS4 controller
│ │ │ ├── info/ # Arm telemetry & joint information
│ │ │ └── view/ # 3D arm visualizer
│ │ └── drive/ # Drive-related components
│ │ ├── camera/ # Camera feed & pan-tilt control
│ │ └── mobility/ # Drive controls & diagnostics
│ │ ├── control/ # Drive controls, headlights, speed
│ │ ├── info/ # Motor diagnostics, speedometer, charts
│ │ └── navigation/ # GPS panel
│ └── ui/ # Generic UI components (buttons, etc.)
│
├── config/ # Configuration files
│ ├── camera.ts # Camera device configurations
│ └── network.ts # Network settings (IP addresses)
│
├── context/ # React contexts
│ └── NavbarContext.tsx # Navbar state management
│
├── hooks/ # Custom React hooks
│ ├── useBandwidthStats.ts # Network bandwidth monitoring
│ ├── useCameraList.ts # Camera device enumeration
│ └── useWebRTCStreams.ts # WebRTC video streaming
│
├── lib/ # Utility libraries
│ └── utils.ts # Common utility functions
│
└── assets/ # Static assets
└── images/ # Image files
public/ # Static files served by Next.js
├── mcgillRobotics.svg # Logo/favicon
└── gamepads/ # PS4 controller button icons
├── base.svg, bumper.svg, circle.svg, etc.
- Camera Feed: Real-time WebRTC video streaming from rover cameras
- Pan-Tilt Control: D-pad interface for camera positioning
-
Mobility Controls:
- Drive control interface
- Headlight toggle
- Maximum speed adjustment knob
-
Diagnostics:
- Real-time speedometer cluster
- Motor diagnostic panels with telemetry
- Performance charts and graphs
- Navigation: GPS panel for location tracking
- Visualizer: Real-time representation of arm position
- PS4 Controller Interface: Visual gamepad for arm control
-
Joint Information:
- Individual joint position and status
- Coordinate display system
- Speed control sliders
- Command Log: History of sent commands
- Performance Graphs: Joint movement and performance charts
- System health monitoring
- Connection status indicators
- Overall rover diagnostics
- Next.js App Router: Modern file-based routing system
- Component Architecture: Modular, reusable components organized by feature
-
Real-time Communication:
- WebRTC for low-latency camera streams
- WebSocket connections for control commands
- HTTP APIs for configuration and status
- WebRTC Streaming: Direct peer-to-peer video streaming
- Device Detection: Automatic camera enumeration and selection
- Bandwidth Monitoring: Real-time network performance tracking
- Auto-reconnection: Automatic stream recovery on connection loss
- Gamepad Integration: PS4 controller support for control
- Real-time Feedback: Live telemetry and status updates
- Safety Features: Speed limiting and emergency stops
- Node.js 18+
- npm or yarn
- Python 3.8+ (for backend services)
- Install frontend dependencies:
cd teleop/robot-controller-ui
npm install
- Install backend service dependencies:
# Install Python dependencies for services
pip install -r requirements.txt
Camera Service (WebRTC Server):
cd teleop/services/camera
python webrtc.py
- Runs on port 8081
- Provides WebRTC signaling and camera device enumeration
- Handles video streaming from V4L2 devices
ROS Services:
# Start ROS2 nodes for robot control
cd teleop/services/ros
python ros_manager.py
cd teleop/robot-controller-ui
npm run dev
- Runs on port 3000 by default
- Hot-reload enabled for development
- Access at
http://localhost:3000
# Build for production
npm run build
# Start production server
npm start
- WebRTC Signaling Server: Handles peer connection establishment
- Device Management: Lists and manages V4L2 camera devices
- Bandwidth Monitoring: Provides real-time streaming statistics
- CORS Support: Enables cross-origin requests from the web UI
- ROS2 Bridge: Connects web interface to ROS2 ecosystem
- Publisher/Subscriber Nodes: Handle command transmission and telemetry
- Message Interfaces: Custom message types for rover communication
-
Frontend:
localhost:3000
-
WebRTC Service:
localhost:8081
-
Camera IP: Configured in
src/config/network.ts
Update src/config/network.ts
to point to your rover's IP address:
export const CAMERAIP = "192.168.1.100" // Replace with rover IP
The application supports these camera types (configured in src/config/camera.ts
):
- USB 2.0 Camera
- Logitech HD Webcam
- VGA USB Camera
- CC HD webcam
-
Components: Add to appropriate section in
src/components/sections/
or insrc/components/ui/
for reusable components -
Pages: Create new routes in
src/app/
-
Hooks: Add custom hooks in
src/hooks/
-
Services: Extend backend services in
teleop/services/
- TypeScript: Strict type checking enabled
- ESLint: Code linting with Next.js configuration
- Tailwind CSS: Utility-first styling approach
- Ensure camera devices are not in use by other applications
- Check V4L2 device permissions:
ls -la /dev/video*
- Verify WebRTC service is running on port 8081
- Check network configuration in
src/config/network.ts
- Ensure all backend services are running
- Verify firewall settings for required ports
- Monitor bandwidth usage in the drive interface
- Check browser console for WebRTC connection errors
- Ensure adequate network bandwidth for video streaming
This project is part of the McGill Robotics rover system. Please refer to the main project license for usage terms.