remote control problem

This commit is contained in:
Helva 2026-02-08 13:23:02 +01:00
parent cafae8a71d
commit f75c654a39
5 changed files with 33 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
drive/opt/drive-ctl/__pycache__/

View File

@ -192,12 +192,26 @@ For Web-UI-Controller you need to have access to the raspberry-pi i.e. via a hot
sudo apt install -y python3-venv
python3 -m venv /opt/drive-ctl-venv
sudo chown -R $USER:$USER /opt/drive-ctl-venv
/opt/drive-ctl-venv/bin/pip install fastapi uvicorn pyserial
source /opt/drive-ctl-venv/bin/activate
pip install fastapi uvicorn pyserial
Configure Arduino-USB-ID
ls -l /dev/serial/by-id/ 2>/dev/null
Example Output
usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB0
Watch USB devices while replugging
dmesg -T | tail -n 80
Configure the USB-Device-ID in /opt/helva-robot/drive/opt/drive-ctl/server.py
### Activate Web Control Interface
@ -223,4 +237,14 @@ Check Serial device is stable, otherwise create a udev rule
http://pi-ip/drive/
### Debug drive-ctl WebUI
check local webservice
curl -s http://127.0.0.1:8002/health
should be -> {"ok": true, ... } -> otherwise look at the logs:
journalctl -u drive-ctl -n 80 --no-pager

View File

@ -1,15 +1,16 @@
location /drive/ {
location ^~ /drive/ {
alias /opt/helva-robot/drive/var/www/drive/;
try_files $uri $uri/ /drive/index.html;
}
location /drive-ws {
location = /drive-ws {
proxy_pass http://127.0.0.1:8002/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 3600;
}
location /drive-health {

View File

@ -5,7 +5,7 @@ import serial
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse
SERIAL_PORT = "/dev/ttyACM0" # ggf. /dev/ttyUSB0
SERIAL_PORT = "/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0" # ggf. /dev/ttyUSB0
BAUD = 115200
# Safety: if websocket stops sending, we also stop.
@ -30,7 +30,7 @@ def send_lr(l: int, r: int):
def health():
return {"ok": True, "serial": SERIAL_PORT}
@app.websocket("/ws")
@app.websocket("/drive-ws")
async def ws(websocket: WebSocket):
global last_msg_ts
await websocket.accept()

View File

@ -2,6 +2,8 @@ server {
listen 80;
server_name _;
include /opt/helva-robot/drive/etc/nginx/snippets/drive.conf;
root /opt/helva-robot/face/var/www/html;
index index.html;
@ -31,6 +33,5 @@ server {
add_header Cache-Control no-cache;
}
include /opt/helva-robot/drive/etc/nginx/snippets/drive.conf;
}