svpcom / wfb-ng

WFB-NG - the next generation of long-range packet radio link based on raw WiFi radio
https://docs.px4.io/main/en/tutorials/video_streaming_wifi_broadcast.html
GNU General Public License v3.0
884 stars 219 forks source link
camera fpv mavlink px4 raspberry-pi rtp telemetry video wfb-ng wifibroadcast

WFB-NG

This is the next generation of long-range packet radio link based on raw WiFi radio

Main features:

:warning: Warranty/Disclaimer
This is free software and comes with no warranty, as stated in parts 15 and 16 of the GPLv3 license. The creators and contributors of the software are not responsible for how it is used. See License and Support for details.

Support project

If you like WFB-ng you can support author via:

Getting Started

For detailed instructions on how to get started read through PX4-Guide and follow the Setup HowTo

Quick start using Raspberry Pi

For putty users don't forget to select: Settings -> Window -> Translation -> Enable VT100 line drawing checkbox before connect.

Quick start using Ubuntu Ground Station

Failing to get connection?

Make sure the WiFi channel on the ground and on the drone are the same. To check, use:

head /etc/wifibroadcast.cfg

You should see output similar to:

[common]
wifi_channel = 161     # 161 -- radio channel @5825 MHz, range: 5815–5835 MHz, width 20MHz
                       # 1 -- radio channel @2412 Mhz, 
                       # see https://en.wikipedia.org/wiki/List_of_WLAN_channels for reference

Ensure the WiFi channel selected is the same on the ground and on the drone.


FAQ

Q: What type of data can be transmitted using WFB-NG?

A: Any UDP with packet size <= 1445. For example x264 inside RTP or Mavlink.

Q: What are transmission guarantees?

A: Wifibrodcast uses FEC (forward error correction) which can recover 4 lost packets from 12 packets block with default settings. You can tune it (both TX and RX simultaneously!) to fit your needs.

Q: Is only Raspberry PI supported?

A: WFB-NG is not tied to any GPU - it operates with UDP packets. But to get RTP stream you need a video encoder (which encodes raw data from camera to x264 stream). In my case RPI is only used for video encoding (because RPI Zero is too slow to do anything else) and all other tasks (including WFB-NG) are done by other board (NanoPI NEO2).

Q: What is a difference from original wifibroadcast?

A: Original version of wifibroadcast uses a byte-stream as input and splits it to packets of fixed size (1024 by default). If radio packets were lost and this is not corrected by FEC you'll get a hole at random (unexpected) place of stream. This is especially bad if data protocol is not resistant to (was not desired for) such random erasures. So i've rewritten it to use UDP as data source and pack one source UDP packet into one radio packet. Radio packets now have variable size depending on payload size. This reduces video latency a lot.

Theory

WFB-NG puts the wifi cards into monitor mode. This mode allows to send and receive arbitrary packets without association and waiting for ACK packets.

Sample usage chain:

Camera -> gstreamer --[RTP stream (UDP)]--> wfb_tx --//--[ RADIO ]--//--> wfb_rx --[RTP stream (UDP)]--> gstreamer --> Display

For encoding logitech c920 camera:

gst-launch-1.0 uvch264src device=/dev/video0 initial-bitrate=6000000 average-bitrate=6000000 iframe-period=1000 name=src auto-start=true \
               src.vidsrc ! queue ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! rtph264pay ! udpsink host=localhost port=5600

To encode a Raspberry Pi Camera V2:

raspivid -n  -ex fixedfps -w 960 -h 540 -b 4000000 -fps 30 -vf -hf -t 0 -o - | \
               gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=35 ! udpsink sync=false host=127.0.0.1 port=5600

To decode:

 gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' \
               ! rtph264depay ! avdec_h264 ! clockoverlay valignment=bottom ! autovideosink fps-update-interval=1000 sync=false

HOWTO build:

For development (inline build)

make

For binary distribution RHEL or Fedora

make rpm

For binary distribution Debian or Ubuntu

sudo apt install python3-all libpcap-dev libsodium-dev python3-pip python3-pyroute2 \
            python3-future python3-twisted python3-serial python3-all-dev iw virtualenv \
            debhelper dh-python build-essential -y
sudo make deb

For binary distribution (tar.gz)

make bdist

You need to generate encryption keys for gs(ground station) and drone:

wfb_keygen

Leave them in place for development build or copy to /etc for binary install. Put drone.key to drone and gs.key to gs.

Supported WiFi hardware:

Wiki:

See https://github.com/svpcom/wfb-ng/wiki for additional info

Community support:

Telegram group: (wfb-ng support) https://t.me/wfb_ng Please note, that it is only one official group.