TRACER
Telemetry-driven Robot with Advanced Control and Execution Routines
System Overview
TRACER is a modern, distributed robotics control system implemented into a robot tank featuring a responsive web-based dashboard, intelligent command processing, and real-time controls. The architecture consists of three interconnected components:
- Frontend Dashboard - Responsive SvelteKit web interface
- Raspberry Pi Controller - Central processing and AI integration
- Arduino Hardware Interface - Sensor management and motor control
The system is designed for mobile-friendly operation, intuitive controls, and expandability.
View docs for detailed architecture and hardware information.
view demos for examples of the web dashboard and command processing.
Key Features
- š® Multi-mode joystick control - Supports arcade, tank, car, and single-joystick modes
- š± Mobile-optimized dashboard - Responsive design for all devices
- š Joystick macro recording - Record, save, and playback movement patterns
- š§ AI-powered commands - Natural language processing for robot control
- š Real-time telemetry - Live sensor data visualization
- š System monitoring - Battery, temperature, and connectivity status
- š Obstacle detection - Proximity awareness with severity levels
- š» Advanced logging - Filterable, searchable system logs
Project Structure
TRACER/
āāā frontend/ # SvelteKit web dashboard
ā āāā src/ # Frontend source code
ā ā āāā lib/ # UI components and utilities
ā ā āāā routes/ # Page routes
āāā backend/ # Intermediary controller code
ā āāā Controller.py # Joystick input processing
ā āāā main.py # Flask web server
āāā rpi/ # Raspberry Pi robot controller
ā āāā src/ # Core robot functionality
ā ā āāā models/ # Robot models and types
ā ā āāā ai/ # GPT integration for commands
ā ā āāā server.py # WebSocket server
āāā arduino/ # Arduino firmware
ā āāā main/ # Main controller sketch
āāā docs/ # Documentation
Technical Architecture
Frontend (Web Dashboard)
Technology: SvelteKit, TypeScript, Socket.IO, TailwindCSS
Key Components:
- Mobile-responsive control dashboard (
src/routes/+page.svelte
)
- Real-time joystick visualization with multiple control modes (
src/lib/components/JoystickStatus.svelte
)
- Command processing and display (
src/lib/components/CommandList.svelte
)
- Joystick macro recording and playback system (
src/lib/components/Recordings.svelte
)
- Telemetry visualization including:
- Obstacle detection (
src/lib/components/ObstructionStatus.svelte
)
- Battery monitoring (
src/lib/components/BatteryPercentage.svelte
)
- System status visualization (
src/lib/components/Status.svelte
)
- Comprehensive logs (
src/lib/components/Logs.svelte
)
Features:
- Responsive design that works on mobile devices
- Real-time updates via WebSockets
- Joystick control with multiple driving modes:
- Two-joystick arcade drive
- Single-joystick arcade drive
- Tank drive
- Car drive (with trigger controls)
- Precision mode toggle for fine control
- Recording and playback of joystick macros
- Command history with visual status indicators
- Comprehensive logging with filtering
- Sensor data visualization
Backend System
Technology: Python, Socket.IO, Flask, PyGame, WebSockets
Components:
Controller Backend (Laptop/Server):
backend/main.py
- Flask server with Socket.IO
backend/Controller.py
- Joystick handling and state management
backend/ControllerState.py
- Control mode enumeration
Robot Controller (Raspberry Pi):
rpi/src/server.py
- Main WebSocket server
rpi/src/models/Robot.py
- Core robot functionality
rpi/src/models/SerialManager.py
- Serial communication
rpi/src/models/SensorData.py
- Sensor data processing
rpi/src/ai/get_commands.py
- Natural language command integration
Features:
- Distributed architecture with dedicated controller and robot servers
- Physical controller support using PyGame
- Multiple control modes (TWO_ARCADE, ONE_ARCADE, TANK, CAR)
- Precision mode toggle for fine control
- Macro recording and playback with named recordings
- Real-time WebSocket communication between components
- Natural language command processing with GPT integration
- Sensor data handling with safety features
- Cliff and obstacle detection with automatic responses
- Command queuing and execution with status feedback
Arduino (Hardware Interface)
Technology: C++, Arduino Framework
Key Components:
- Main control loop (
arduino/main/main.ino
)
- Sensor interface modules
- Motor control system
- Serial communication handler
Hardware Components:
- TB6612FNG motor driver for differential drive
- MPU6050/9250 IMU (gyroscope + accelerometer)
- 1602 LCD with I2C backpack for local status display
- IR sensors for cliff detection
- HC-SR04 ultrasonic sensor for distance measurement
Features:
- Real-time sensor data collection and processing
- Motor control with hardware PWM
- Safety-first design with emergency stops
- Serialized data communication with the Raspberry Pi
- Local status display on LCD
- Battery voltage monitoring
- Obstacle and cliff detection
Communication System
Communication Flow
User Input (Web UI/Controller) ā Backend Socket ā Raspberry Pi ā Serial ā Arduino ā Sensors
ā
Telemetry Display (Web UI) ā Backend Socket ā Raspberry Pi ā Serial Data ā Arduino
Socket.IO Events
Frontend ā Backend:
joystick_input
: Send joystick control values to backend
joystick_mode
: Control mode changes (TWO_ARCADE, ONE_ARCADE, TANK, CAR)
precision_mode
: Toggle for precise movement control
start_recording
: Begin recording joystick movements
stop_recording
: End recording and save macro
play_recording
: Play back a saved joystick macro
sensor_data
: Streaming sensor updates from robot
active_command
: Current command being executed
Backend ā Raspberry Pi:
query
: Send natural language commands for AI processing
joystick_input
: Forward controller commands
sensor_data
: Telemetry updates
rumble
: Trigger controller haptic feedback
stop
: Emergency stop command
Serial Protocol (Raspberry Pi ā Arduino)
Command Structure:
- Motor control: Binary packet with header and motor values
- LCD commands: Text display instructions
- Sensor requests: Periodic polling for data
Response Structure:
- Sensor data packets with ultrasonic, IMU, and IR readings
- Status acknowledgements
- Error messages
Safety Features
- Emergency stop capability at all levels (UI, controller, code)
- Cliff detection with automatic stopping
- Obstacle avoidance with configurable thresholds
- Connection monitoring with auto-shutdown on disconnect
- Battery voltage monitoring and low-power warnings
- Watchdog timers for system stability
Development and Deployment
Requirements:
- Python 3.10+ for backend and Raspberry Pi code
- Node.js and npm for frontend development
- Arduino IDE for firmware updates
Running the System:
- Ensure all dependencies are installed:
- For frontend:
npm install
in the frontend
directory
- For backend: Create venv and run
pip install -r requirements.txt
in the backend
directory
- For Raspberry Pi: Create venv and run
pip install -r requirements.txt
in the rpi
directory
- Upload
arduino/main/main.ino
to the Arduino board using the Arduino IDE
- Run the raspberry Pi server:
- Navigate to the
rpi
directory and run python -m main
- Connect xbox controller to the laptop or server running the backend
- Ensure the controller is recognized by the system (use
jstest
or similar tools to verify)
- Start the backend server:
- Navigate to the
backend
directory and run python main.py
- Start the frontend server:
- Navigate to the
frontend
directory and run npm run dev
- Open the web dashboard in a browser at
http://localhost:5173
Future Enhancements
- Enhanced autonomous navigation capabilities
- Pure pursuit path following and PID control for smoother movement
- Motor encoders for precise localization
- Custom shield and mounts
- Camera integration for computer vision tasks
- Visual SLAM for mapping and localization
- Multi-robot coordination
- Additional sensor integration
- Machine learning for behavior optimization
- Mobile app control interface