Developer

FPV setup with raspberry Pi

3689553118?profile=original

After much chasing, and testing, I have found this to be an efficient way of getting low latency high quality HD video out of an Aircraft. The latency is around 0.4 seconds at worst which would be OK for an FPV with an APM doing the hard work.

I will continue to search for methods to drop the latency down further, but this is a lot better than the 6-12 seconds I was getting on my first attempts.

Any comment (with useful instructions) would be appreciated.

For the wireless link, I am using two UBIQUITY ROCKET M 900 with Australian ACMA approved firmware, at the base station, I am using a tracking (yet to built the tracker...) 1.5 meter long X and Y polarised Yagi, and on the plane, two RF Design flexible strip antennas, placed at right angles to each other.

but how you do that bit is up to you.....

the critical bit is getting the Raspberry Pi's to chat to each other.

I have tried to make this as user friendly as possible... good luck.

 

Setting up IP video for Raspberry Pi 1080p video (FPV)

 

You will need 2 B model Raspberry Pi's and 1 Pi Camera. (Element 14, or RS components)

Preparing your Raspberry Pi for first boot…

 

Follow the instructions at http://www.raspberrypi.org/wp-content/uploads/2012/04/quick-start-guide-v2_1.pdf

Install the prepared SD card in the Pi and boot.

Setting up your Pi

Connect the Pi to your router with a network cable.

On Start-up it will resize the FAT partition and present you with a menu.

Set your language, and keyboard layout.

Select Raspbian… then click install.

After this has extracted (will take a while….) it will reboot into the configuration screen (again will take a while for this first boot.)

The important things to change here are

  1. Enable the camera
  2. In advance options…..
    1. Set the host name (camera, for the camera end, receiver, for the viewing end)
    2. Memory split, set the memory for the GPU to 256
    3. Enable SSH ( will come in handy later, as you may need to talk to the Pi in the air.....

Then finish and reboot.

First login

Username: pi

Password: raspberry

Setting up the required programs for video streaming

 

Install the dependencies by running the following in a terminal:

sudo apt-get install mplayer netcat

cd /opt/vc/src/hello_pi

make –C libs/ilclient

make –C libs/vgfont

cd /opt/vc/src/hello_pi/hello_video

make

cd ~

Now repeat this for the other Pi….

 

Streaming…

First set up the receiver….

Ensure the receiver is connected to your network and run

ifconfig

after you press enter, you can find your ip Address.  Note this down.

Then run the following.

mkfifo buffer

nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer

the Pi will now wait for the feed.

On the Camera Pi

Ensure camera is connected to the Pi

Ensure Pi is connected to the network (you can confirm this with ifconfig)

(see instructions at http://www.raspberrypi.org/camera for how to connect the camera)

 

 

In the following command, replace the ip address with the one you just noted down.

raspivid -t 0 -fps 15 -o - | nc 192.168.1.85 5001

if all goes well you should be streaming 1080P video at 15fps with less than 0.5seconds of delay..

now add your wireless bridge between the two, and away you go J

This information has come from the Raspberry Pi foundation website, and other sources, tested and proven by myself..

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • @Patrick

    Right now Im using 

    raspivid -w 800 -h 720 -fps 15 -t 999999 -b 2000000 -o - | nc -u 192.168.0.107 5001

    And on the receiving end Im using Windows 8 and MPlayer:

    nc.exe -Lu -p 5001 | mplayer.exe -fps 15 -demuxer h264es -

    Im testing it now to see if/how the latency changes over time. Right now the Pi is connected to my home network over ethernet and the Windows laptop is connected with built in wifi. I should have some wifi dongles to try tomorrow.

    I also figured out the problem with my telemetry, heres the command:

    2001:raw:600:/dev/ttyAMA0:115200 NONE 1STOPBIT 8DATABITS -XONXOFF LOCAL -RTSCTS
    6001:raw:0:/dev/ttyAMA0:115200 remctl banner1

    Originally I had port 6001 as telnet protocol instead of raw and that was only giving me partial data. After switching to raw Im getting full serial connectivity with my AutoQuad over my network.

     

  • It's a great little project – I'm a bit of a dilettante when it comes to mechanics and electronics, so it's good to be back in my comfort zone with software =) Will keep you posted.

  • Looks good to me; cant wait to see what you come up with!  I've spent most of my time focused on the hardware side, and am a bit lacking on the software side, so sharing what you put together would be much appreciated!

  • (Of course, it's going to be specific to the inputs available to the pi - it probably won't speak APM...)

  • Working on that as we speak, all built around python and GStreamer =) I plan to make it open source once done, and easily installable.

    3701663976?profile=original

  • Too bad I cant get g-streamer working on my windows machine...!  I liked the idea of pi to pi streaming, but love having the ability to overlay the HUD and monitor my wifi signal strength all on the same display.  If I could only manage an overlay with the pi to pi stream i'd be in heaven..

  • I see your 200ms and I raise you a 180ms:

    Transmit side:

    raspivid -n -w 1280 -h 720 -b 1000000 -fps 30 -vf -hf -t 0 -pf high -o - | gst-launch-1.0 -v fdsrc !  h264parse ! rtph264pay ! udpsink host=192.168.0.14 port=9000

    Receive side:

    gst-launch-1.0 udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! queue max-size-time=100 ! eglglessink sync=false

     

    (Needs "deb http://vontaene.de/raspbian-updates/ . main" added to /etc/apt/sources, and sudo apt-get install gstreamer-tools-1.0 gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad)

    Index of /raspbian-updates
  • I used ser2net before, but that cannot setup UDP. Instead i use THIS and connect the ethernet port directly into my raspberry pi's ethernet port and route the UDP traffic via the RPi and out on 3g :)

  • What commands are you using for the UDP streaming?  My latency stays right at 200ms through a full pack, and I've had i've had it running for more than an hour around the office with no increase in latency.  What are you using for commands on server/receiver?

    What are you using for wireless hardware?  I've had VERY good luck with the 5.8ghz Ubiquiti equipment.  Just picked up a couple Mikrotik Routerboard's at 2.4ghz for testing just for the heck of it.

     

    I'd be interested to see your sert2net commands and how you have teh telemetry streaming setup... 

  • Been playing with this and over ethernet Ive gotten video streaming with netcat over UDP working pretty well so far although I think the lag may be increasing over time but it starts at under 1s. Ive also been working on using ser2net to forward Mavlink telemetry over TCP and its only partially working.

    Im using an AutoQuad flight controller and tried both connecting with an FTDI cable to the Raspberry Pi USB port and connecting directly to the GPIO on the Pi and the result in both cases is Im able to get IMU data on the GCS (moving virtual horizon) but no other data. Im not getting GPS or any parameters. 

This reply was deleted.