Compare commits

..

No commits in common. "4b040391da2e92849b55fa3986bbe4bd98ff24d7" and "cafae8a71d2ba67657e92c907ab4e9a30113cda2" have entirely different histories.

6 changed files with 7 additions and 52 deletions

1
.gitignore vendored
View File

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

View File

@ -193,25 +193,11 @@ For Web-UI-Controller you need to have access to the raspberry-pi i.e. via a hot
sudo apt install -y python3-venv sudo apt install -y python3-venv
python3 -m venv /opt/drive-ctl-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 /opt/drive-ctl-venv/bin/pip install fastapi uvicorn pyserial
source /opt/drive-ctl-venv/bin/activate source /opt/drive-ctl-venv/bin/activate
pip install fastapi uvicorn pyserial 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 ### Activate Web Control Interface
@ -237,14 +223,4 @@ Check Serial device is stable, otherwise create a udev rule
http://pi-ip/drive/ 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,16 +1,15 @@
location ^~ /drive/ { location /drive/ {
alias /opt/helva-robot/drive/var/www/drive/; alias /opt/helva-robot/drive/var/www/drive/;
try_files $uri $uri/ /drive/index.html; try_files $uri $uri/ /drive/index.html;
} }
location = /drive-ws { location /drive-ws {
proxy_pass http://127.0.0.1:8002/ws; proxy_pass http://127.0.0.1:8002/ws;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_read_timeout 3600;
} }
location /drive-health { location /drive-health {

View File

@ -5,11 +5,11 @@ import serial
from fastapi import FastAPI, WebSocket, WebSocketDisconnect from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse from fastapi.responses import HTMLResponse
SERIAL_PORT = "/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0" # ggf. /dev/ttyUSB0 SERIAL_PORT = "/dev/ttyACM0" # ggf. /dev/ttyUSB0
BAUD = 115200 BAUD = 115200
# Safety: if websocket stops sending, we also stop. # Safety: if websocket stops sending, we also stop.
STOP_AFTER_SEC = 0.5 STOP_AFTER_SEC = 0.35
app = FastAPI() app = FastAPI()
@ -35,9 +35,6 @@ async def ws(websocket: WebSocket):
global last_msg_ts global last_msg_ts
await websocket.accept() await websocket.accept()
last_msg_ts = time.time()
send_lr(0, 0)
async def watchdog(): async def watchdog():
while True: while True:
await asyncio.sleep(0.05) await asyncio.sleep(0.05)

View File

@ -265,22 +265,7 @@
lastL = L; lastR = R; lastL = L; lastR = R;
readoutEl.textContent = `T ${throttle.toFixed(2)} | Turn ${turn.toFixed(2)} → L ${L} | R ${R}`; readoutEl.textContent = `T ${throttle.toFixed(2)} | Turn ${turn.toFixed(2)} → L ${L} | R ${R}`;
// sendLR(L, R, force); sendLR(L, R, force);
// ---- Heartbeat: keep sending current values while driving ----
setInterval(() => {
// wenn nicht verbunden -> nix
if (!connected) return;
// Wenn du NUR beim aktiven Fahren senden willst:
const driving = (Math.abs(throttle) > 0.02) || (Math.abs(turn) > 0.02);
if (driving) {
// erzwinge Senden auch wenn sich nichts geändert hat
sendLR(lastL, lastR, true);
}
}, 400); // 40 Hz
} }
function hardStop() { function hardStop() {

View File

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