Robot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Hendrik Langer d222e93159 speed up camera_pi mjpeg stream 4 years ago
raspberry speed up camera_pi mjpeg stream 4 years ago
trigorilla send voltage 4 years ago
.gitignore Initial commit 4 years ago
LICENSE initial commit 4 years ago
README.md systemd unit 4 years ago
send.py initial commit 4 years ago

README.md

roberto

Robot

Prepare

sudo systemctl --full --force edit wifi_powersave@.service

[Unit] Description=Set WiFi power save %i After=sys-subsystem-net-devices-wlan0.device

[Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/iw dev wlan0 set power_save %i

[Install] WantedBy=sys-subsystem-net-devices-wlan0.device

rpi ~$ sudo systemctl disable wifi_powersave@on.service rpi ~$ sudo systemctl enable wifi_powersave@off.service

Test certificate

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj '/CN=localhost'

Camera test

raspivid -a 12 -t 0 -w 1280 -h 720 -vf -ih -fps 30 -l -o tcp://0.0.0.0:5000

mplayer -x 1280 -y 720 -geometry 0:0 -fps 200 -demuxer h264es -noborder ffmpeg://tcp://172.16.85.221:5000

sudo apt install gstreamer1.0-tools

Sender (Pi): gst-launch-1.0 -e v4l2src do-timestamp=true ! video/x-h264,width=640,height=480,framerate=30/1 ! h264parse ! rtph264pay config-interval=1 ! gdppay ! udpsink host=192.168.178.20 port=5000

Receiver: gst-launch-1.0 -v udpsrc port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=false

debugging

export GST_DEBUG=webrtc:7 export G_MESSAGES_DEBUG=all

documentation

https://flask-socketio.readthedocs.io/en/latest/

https://github.com/pfertyk/webrtc-working-example

https://github.com/nanomosfet/WebRTC-Flask-server/blob/master/webRTCserver/webRTCserver.py

http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html https://gitlab.freedesktop.org/gstreamer/gst-examples/-/tree/master/webrtc/sendrecv/gst

https://github.com/thaytan/gst-rpicamsrc/blob/master/examples/webrtc-unidirectional-h264.c

https://github.com/centricular/gstwebrtc-demos/blob/master/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c https://gitlab.freedesktop.org/gstreamer/gst-examples/-/blob/master/webrtc/multiparty-sendrecv/gst-rust/src/main.rs

https://github.com/aiortc/aiortc/blob/main/examples/webcam/webcam.py

nginx.conf

map $http_upgrade $connection_upgrade {
	default	upgrade;
	''	close;
}

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;
	server_name roberto.xd0.de;

	ssl_certificate /etc/letsencrypt/live/roberto.xd0.de/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/roberto.xd0.de/privkey.pem;
	include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

	access_log	/var/log/nginx/roberto_access.log;
	error_log	/var/log/nginx/roberto_error.log;

	root /var/www/html;

	index index.html index.htm;

	proxy_buffering off;

	location / {
		include proxy_params;
#		client_max_body_size	0;
		proxy_pass http://172.16.85.42:5000;
	}

#	location /static {
#		alias <path-to-your-application>/static;
#		expires 30d;
#	}

	location /socket.io {
		include proxy_params;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_http_version 1.1;
		proxy_buffering off;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		proxy_pass http://172.16.85.42:5000/socket.io;
	}

	location ~ /\.ht {
		deny all;
	}
}

/etc/systemd/system/roberto.service

[Unit]
Description=Roberto Python
Wants=network.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/roberto
ExecStart=/usr/bin/env /home/pi/roberto/raspberry/roberto.py
Restart=on-failure

[Install]
WantedBy=multi-user.target

chmod a+x /home/pi/roberto/raspberry/roberto.py systemctl daemon-reload systemctl enable roberto systemctl start roberto