A remote-controlled car project based on a Raspberry Pi, controlled over WebSockets using Ktor.
The car uses a PCA9685 PWM driver to control a servo (steering) and a brushless ESC + motor (throttle).
- WebRTC video streaming for FPV control
- GTA-style remote control with keyboard/touch controls and 50Hz control loop
- WebSocket control interface (Ktor)
- Servo-based steering using Diozero + PCA9685
- Brushless ESC motor throttle control via PWM
- Hardware calibration API and web UI for tuning steering and motor parameters
- Configuration management via YAML (application.yaml)
- Modular hardware abstraction (
ServoManager,MotorManager,CarController) - Safety features: Deadman switch, 250ms failsafe timeout
| Component | Model |
|---|---|
| SBC | Raspberry Pi 4 B+ |
| PWM Driver | PCA9685 (I2C, address 0x40) |
| Steering | Etronix ES060 servo |
| Motor | Surpass Hobby 2430 Brushless |
| ESC | Surpass Hobby 25A |
| Camera | Raspberry Pi Camera Module (WebRTC via MediaMTX) |
For complete hardware details, wiring diagrams, and setup instructions, see docs/HARDWARE.md.
- Deploy to Pi: Use the IntelliJ run configuration or
./scripts/deploy.sh - Start camera:
sudo mediamtx /etc/mediamtx.yml(on Pi) - Open control page:
http://<pi-ip>:8080/ - Drive! Hold SPACE (deadman) and use WASD to control
- SSH access to your Raspberry Pi configured (password-less recommended)
rsyncinstalled on your Mac
The project includes ready-to-use run configurations:
| Configuration | Description |
|---|---|
| Deploy to Pi | Build, deploy, and run on Raspberry Pi |
| Deploy to Pi (Debug) | Same as above, with remote debugging enabled |
| Stop Pi-Car | Stop the running application on Pi |
| Pi-Car Status | Check if app is running and test API |
| Pi-Car Remote Debug | Attach debugger to running app |
# Build and deploy
./scripts/deploy.sh
# Deploy with debug enabled
./scripts/deploy.sh --debug
# Stop the app
./scripts/stop.sh
# Check status
./scripts/status.sh- Run "Deploy to Pi (Debug)" to start the app with debug agent
- Run "Pi-Car Remote Debug" to attach the debugger
- Set breakpoints in your code and debug as usual!
The app will listen for debugger on port 5005.
Edit scripts/deploy.sh to change Pi connection settings:
PI_HOST=# Your Pi SSH address
PI_PATH=# Deployment pathThe project includes a comprehensive calibration system to fine-tune your steering and motor settings.
- Start the Pi-Car server (use "Deploy to Pi")
- Open
http://PI_IP:8080/in your browser - The calibration tool loads automatically
- Use the sliders to test and adjust values
- Save your calibration settings
For advanced users, use the REST API directly. See docs/CALIBRATION.md for detailed instructions.
Key Endpoints:
GET /calibration- Get current calibration valuesPOST /calibration/steering/angle- Test steering at specific anglePOST /calibration/motor/throttle- Test motor throttlePATCH /calibration/steering- Update steering calibrationPATCH /calibration/motor- Update motor calibration
Hardware settings are stored in src/main/resources/application.yaml:
hardware:
servo:
channel: 0
minPulseUs: 1300
maxPulseUs: 1800
centerPulseUs: 1500
leftPulseUs: 1750
rightPulseUs: 1350
motor:
channel: 1
neutralPulseUs: 1500
forwardMinPulseUs: 1590
forwardMaxPulseUs: 1700
reverseMaxPulseUs: 1410
reverseMinPulseUs: 1300Use the calibration tool to find optimal values, then update this file.
- Always start with neutralThrottle() to arm ESC
- Never exceed PSU current limit beyond motor rating
- Disconnect servo power (V+) if unnecessary — some ESCs backfeed voltage
- Monitor PSU for OCP (Overcurrent Protection) triggers during testing
- docs/HARDWARE.md - Complete hardware setup, wiring, and camera configuration
- docs/CALIBRATION.md - Complete calibration API reference
- docs/QUICKSTART_CALIBRATION.md - 15-minute calibration quick start
- docs/SECURITY.md - Security setup guide (credentials & SSH keys)
Web UI: Open your browser to http://<pi-ip>:8080/ when the server is running.