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
1k stars 238 forks source link

Detailed installation and setup guide for RPI #53

Closed Yes21 closed 3 years ago

Yes21 commented 4 years ago

As many of you I find it a nightmare to install and configure WFB, because the wiki is very incomplete and is missing detailed informations. Especially for a noobs like me :)

So I've begin to write a very detailed guide and want to share it with you. But I'm still missing informations.

Please don't hesitate to correct it, and to add what is missing ...

Many thanks for advance.

Note : This guide isn't yet finished, and not yet perfect, because I don't have WFB working for now !! Some things should be wrong or missing ...

Yes21 commented 4 years ago

Note : Image Builder was modified for compiling kernels with "CONFIG_NET_SCHED=y, CONFIG_NET_SCH_FIFO=y, CONFIG_PROC_CHILDREN=y" and installing the patched aircrack-ng rtl8812au driver (https://github.com/svpcom/rtl8812au).

ssh pi@192.168.0.xx password = raspberry

sudo -s apt-get update

[Install libsodium]

apt-get install libsodium18

[Install mavlink-router]

git clone https://github.com/intel/mavlink-router
cd mavlink-router/
git submodule update --init --recursive
./autogen.sh && ./configure CFLAGS='-g -O2' \
        --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 \
    --prefix=/usr
make
make install
cd ..
rm -rf mavlink-router

[Install gstreamer]

wget https://github.com/OpenHD/gst-raspberrypi/releases/download/1.10.4-stretch/GStreamer-1.10.4-stretch.tar.gz
tar xvf GStreamer-1.10.4-stretch.tar.gz
dpkg -i GStreamer-1.10.4-stretch/*.deb
rm GStreamer-1.10.4-stretch.tar.gz
rm -rf GStreamer-1.10.4-stretch

[Install some dependencies]

apt-get install python3-virtualenv virtualenv
apt-get install python-twisted libpcap-dev libsodium-dev python-pyroute2 python-future python-configparser python-all
pip install --upgrade pyroute2
sudo apt install gstreamer1.0-libav

[Install wifibroadcast]

cd ~
git clone https://github.com/svpcom/wifibroadcast.git
cd wifibroadcast
make deb
cd deb_dist
dpkg -i wifibroadcast*.deb

[Generate the keys for encryption]

wfb_keygen
cp *.key /etc

[Create the wifibroadcast conf file]

cd /etc
> wifibroadcast.cfg

nano wifibroadcast.cfg copy these lines into it and adapt the values for your needs :


[common]
wifi_channel = 161     # 161 -- radio channel @5805 MHz, range: 5795–5815 MHz, width 20MHz
                       # 1 -- radio channel @2412 Mhz, 
                       # see https://en.wikipedia.org/wiki/List_of_WLAN_channels for reference
wifi_region = 'BO'     # Your country for CRDA (use BO or GY if you want max tx power) 

[gs_mavlink]
peer = 'connect://127.0.0.1:14550'  # outgoing connection
 # peer = 'listen://0.0.0.0:14550'   # incoming connection

bandwidth = 20     # bandwidth 20 or 40 MHz
short_gi = False   # use short GI or not
stbc = 1           # stbc streams: 1, 2, 3 or 0 if unused
mcs_index = 1      # mcs index

[gs_video]
peer = 'connect://127.0.0.1:5600'  # outgoing connection for
                                   # video sink (QGroundControl on GS)

bandwidth = 20     # bandwidth 20 or 40 MHz
short_gi = False   # use short GI or not
stbc = 1           # stbc streams: 1, 2, 3 or 0 if unused
mcs_index = 1      # mcs index

[drone_mavlink]
peer = 'listen://0.0.0.0:14550'   # incoming connection
# peer = 'connect://127.0.0.1:14550'  # outgoing connection

bandwidth = 20     # bandwidth 20 or 40 MHz
short_gi = False   # use short GI or not
stbc = 1           # stbc streams: 1, 2, 3 or 0 if unused
mcs_index = 1      # mcs index

[drone_video]
peer = 'listen://0.0.0.0:5602'  # listen for video stream (gstreamer on drone)

bandwidth = 20     # bandwidth 20 or 40 MHz
short_gi = False   # use short GI or not
stbc = 1           # stbc streams: 1, 2, 3 or 0 if unused
mcs_index = 1      # mcs index

[Create a conf file for mavlink-router]

mkdir /etc/mavlink-router
> /etc/mavlink-router/main.conf

Edit this file and copy into it :

nano /etc/mavlink-router/main.conf


[UdpEndpoint wifibroadcast]
Mode = Normal
Address = 127.0.0.1
Port = 14550

[UartEndpoint ardupilot]
Device = /dev/serial0
Baud = 57600

[Set the right interface in /etc/default/wifibroadcast]

Edit /etc/default/wifibroadcast and repace wlan0 with proper wifi interface name :

nano /etc/default/wifibroadcast

(wlan0 should work if you have only one wifi board connected to the Pi, but it's better to use the MAC address of the boards because they never change.)

[create the wifi access point for connecting QGC ?]

I don't know were to configure it : board, band, SSID, pass ?

[put the start sequences in /etc/rc.local]

nano /etc/rc.local

and add to it (before "exit 0) :


# uncomment for gs
# sudo systemctl start wifibroadcast@gs

# uncomment for drone
# sudo systemctl start wifibroadcast@drone
# mavlink-routerd &
# for RPI cam
# (raspivid --nopreview --awb auto -ih -t 0 -w 640 -h 360 -fps 49 -b 4000000 -g 147 -pf high -o - | gst-launch-1.0 fdsrc ! h264parse !  rtph264pay !  udpsink host=127.0.0.1 port=5602 &)
# or
# (raspivid --nopreview --awb auto -ih -t 0 -w 1280 -h 720 -fps 49 -b 4000000 -g 147 -pf high -o - | gst-launch-1.0 fdsrc ! h264parse !  rtph264pay !  udpsink host=127.0.0.1 port=5602 &)
# for Logitech camera C920 camera
# gst-launch-1.0 uvch264src device=/dev/video0 initial-bitrate=4000000 average-bitrate=4000000 iframe-period=3000 name=src auto-start=true \  src.vidsrc ! queue ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay ! udpsink host=localhost port=5602

[give anybody the right to modify files to be modified]

chmod 777 /etc/wifibroadcast.cfg
chmod 777 /etc/mavlink-router/main.conf
chmod 777 /etc/default/wifibroadcast
chmod 777 /etc/rc.local

PS : Using this guide I'm able to build an unique image which can work on both drone and gs Pi which few modifications (see attached Howto) HOWTO_SETUP.txt

Mysnomer0 commented 4 years ago

Hi Yes21,

First off, I'm glad to see someone working with and using the wifibroadcast project! :) Second, check out the guide I contributed to the wiki, a detailed installation and setup guide for RPI running a specific setup:

https://github.com/svpcom/wifibroadcast/wiki/Navio2-Setup

Hope this helps on the parts you're confused! If you have any questions or enhancements to my guide, let me know and we can ask svpcom to add it to the wiki.

Thanks,

Milan

Yes21 commented 4 years ago

Hi Milan,

Many thanks for your answer ! I didn't see your guide in the wiki. Sorry ...

I'm sure I will find in it some useful informations for my guide. I will return to you later if I need more precisions.

Yves

Mysnomer0 commented 4 years ago

Hi Yves,

Are you able to access the link in my previous comment? Or, if you look in the wiki, hopefully you'll see "Navio2-Setup". That's it!

Thanks,

Milan

Yes21 commented 4 years ago

Hi Milan, Many thanks for your help. I've read your guide and think I understood where to put the pipeline. I've edited my guide, so you could perhaps verify if that' correct.

It's now missing me how to create an access point and to redirect video and telemetry flows for QGC.