remote control problem
This commit is contained in:
parent
cafae8a71d
commit
f75c654a39
|
|
@ -0,0 +1 @@
|
||||||
|
drive/opt/drive-ctl/__pycache__/
|
||||||
26
README.md
26
README.md
|
|
@ -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
|
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
|
||||||
|
|
||||||
|
|
@ -223,4 +237,14 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
|
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ 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/ttyACM0" # ggf. /dev/ttyUSB0
|
SERIAL_PORT = "/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0" # ggf. /dev/ttyUSB0
|
||||||
BAUD = 115200
|
BAUD = 115200
|
||||||
|
|
||||||
# Safety: if websocket stops sending, we also stop.
|
# Safety: if websocket stops sending, we also stop.
|
||||||
|
|
@ -30,7 +30,7 @@ def send_lr(l: int, r: int):
|
||||||
def health():
|
def health():
|
||||||
return {"ok": True, "serial": SERIAL_PORT}
|
return {"ok": True, "serial": SERIAL_PORT}
|
||||||
|
|
||||||
@app.websocket("/ws")
|
@app.websocket("/drive-ws")
|
||||||
async def ws(websocket: WebSocket):
|
async def ws(websocket: WebSocket):
|
||||||
global last_msg_ts
|
global last_msg_ts
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ 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;
|
||||||
|
|
||||||
|
|
@ -31,6 +33,5 @@ server {
|
||||||
add_header Cache-Control no-cache;
|
add_header Cache-Control no-cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
include /opt/helva-robot/drive/etc/nginx/snippets/drive.conf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue