184 lines
4.3 KiB
Markdown
184 lines
4.3 KiB
Markdown
# Helva Roboter
|
|
|
|
We build a robot with raspberry and arduino.
|
|
|
|
## Checkout Repo
|
|
cd /opt
|
|
git checkout https://git.dyn.mcf.at/Max/helva-robot.git
|
|
|
|
## Raspberry Face
|
|
|
|
### Install Packages
|
|
sudo apt update
|
|
sudo apt install -y nginx python3 python3-venv
|
|
|
|
sudo mkdir -p /opt/face
|
|
sudo chown -R $USER:$USER /opt/face
|
|
|
|
python3 -m venv /opt/face/venv
|
|
/opt/face/venv/bin/pip install --upgrade pip
|
|
/opt/face/venv/bin/pip install fastapi uvicorn
|
|
|
|
### Exchange Nginx Web-Folder
|
|
sudo rm -r /var/www/html
|
|
sudo ln -s /opt/helva-robot/face/var/www/html/ /var/www/
|
|
|
|
### Permissions of Webfolder
|
|
sudo chown -R www-data:www-data /var/www/html
|
|
|
|
### Nginx Vhost
|
|
sudo ln -s /opt/helva-robot/face/etc/nginx/sites-available/face /etc/nginx/sites-enabled/
|
|
|
|
### Restart nginx
|
|
sudo systemctl restart nginx
|
|
|
|
### Test Face Server
|
|
#### In Browser
|
|
http://pi-ip/
|
|
|
|
#### From Somewhere
|
|
|
|
`Neutral + wander`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"emotion":"neutral","intensity":0.6,"look":null}'
|
|
|
|
`Angry + starring right`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"emotion":"angry","intensity":0.9,"look":{"x":0.9,"y":0.0}}'
|
|
|
|
`start Talking`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"talk":{"enabled":true}}'
|
|
|
|
`talk faster and stronger`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"talk":{"enabled":true,"rate_hz":5.5,"amount":1.0,"jitter":0.35}}'
|
|
|
|
`stop talking`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"talk":{"enabled":false}}'
|
|
|
|
`emotion + talk`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"emotion":"happy","intensity":0.85,"talk":{"enabled":true,"rate_hz":4.2,"amount":0.95}}'
|
|
|
|
`blink + happy`
|
|
|
|
curl -X POST http://<pi>/api/state -H "Content-Type: application/json" \
|
|
-d '{"emotion":"happy","blink":true,"intensity":0.85}'
|
|
|
|
### systemd Service
|
|
sudo ln -s /opt/helva-robot/face/etc/systemd/system/face.service /etc/systemd/system/
|
|
|
|
sudo chown -R www-data:www-data /opt/face
|
|
sudo chmod -R 755 /opt/face
|
|
|
|
Start:
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now face.service
|
|
sudo systemctl status face.service --no-pager
|
|
|
|
### Face Control UI
|
|
http://localhost/control/
|
|
|
|
### Debug Face
|
|
|
|
#### SSE-Stream going to browser?
|
|
curl -N http://127.0.0.1:8001/events | head
|
|
|
|
#### is nginx delivering /events through
|
|
curl -N http://localhost/events | head
|
|
|
|
#### check Endpoint /api/state
|
|
`directly`
|
|
curl -s -X POST http://127.0.0.1:8001/api/state \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"emotion":"happy","intensity":0.9,"blink":true}' | jq
|
|
|
|
`throught nginx`
|
|
curl -s -X POST http://localhost/api/state \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"emotion":"happy","intensity":0.9,"blink":true}'
|
|
|
|
#### check python face server
|
|
sudo systemctl status face.service --no-pager
|
|
sudo journalctl -u face.service -n 50 --no-pager
|
|
|
|
#### restart/reload face server service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl restart face.service
|
|
|
|
#### check listening Port
|
|
sudo ss -ltnp | grep :8001
|
|
|
|
#### restart/status of face service
|
|
sudo systemctl restart face.service
|
|
sudo systemctl status face.service --no-pager
|
|
|
|
## Arduino Motor Steering
|
|
|
|
### Pin assignment Arduino -> 2 pcs Motor-Driver-Boards (BTS7960)
|
|
- one BTS7960 is for the two left 12V DC motors in parallel
|
|
- one BTS7960 is for the two right 12V DC Motors
|
|
|
|
Caution! This drivers only work for DC Motors. For stepper motors you will need different motor drivers.
|
|
|
|
|
|
#### Left BTS#1
|
|
Power
|
|
|
|
- VCC -> Arduino 5V
|
|
- GND -> Arduino GND
|
|
|
|
Steering - NEVER activate both directions at once!!!
|
|
|
|
- RPWM -> Arduino D5 (PWM)
|
|
- LPWM -> Arduino D6 (PWM)
|
|
|
|
Enabled - either directly 5V or steer it from arduino
|
|
|
|
- R_EN -> Arduino D7
|
|
- L_EN -> Ardiono D8
|
|
|
|
|
|
#### Right BTS#2
|
|
Power
|
|
|
|
- VCC -> Arduino 5V
|
|
- GND -> Arduino GND
|
|
|
|
Steering - NEVER activate both directions at once!!!
|
|
|
|
- RPWM -> Arduino D9 (PWM)
|
|
- LPWM -> Arduino D10 (PWM)
|
|
|
|
Enabled - either directly 5V or steer it from arduino
|
|
|
|
- R_EN -> Arduino D11
|
|
- L_EN -> Ardiono D12
|
|
|
|
|
|
### Arduino Steering Code
|
|
|
|
Upload to Arduino:
|
|
drive/arduino-sketch/arduino-sketch.ino
|
|
|
|
### Test with Arduino Serial Monitor
|
|
|
|
slow forward
|
|
|
|
f 60
|
|
|
|
slow backward
|
|
|
|
r 60
|
|
|
|
|