Part Two: Here is the original picture of the finished product:

3689618661?profile=original

This is the second part of a 2-part series on 'How to build a High-Definition FPV UAV using a Raspberry PI with HD camera, using a high speed WiFi link.

In my first post on the subject (located here), I discussed the parts I used, and how to install them into a Hobby King Go-Discover FPV model. 

In this post, I will discuss installing the Raspberry PI and the PI camera in the Go-Discover gimbals, and the software configuration for both the Raspberry PI and the ground station PC.

From the previous post, step 3 was completed by installing the Ubiquity Rocket M5 in the model.  Now onto step 4:

Step 4: Install the Raspberry PI and PI Camera

Here is a photo of the position of the PI in the Go-Discover model:

3689618887?profile=original

The PI fits nicely just behind the camera gimbals, with the USB and HDMI ports on top. In the right side you can see the Cat5 network cable attached. This cable connects to the ethernet switch, which is also connected to the Rocket M5 input port.  

The two cables shown on top are the servo control wires for the gimbals, which I have directly connected to channel 4 and 5 on my radio.  I am using channel 4 (normally the rudder stick on my radio. Since there is no rudder on a flying wing, this is a convenient channel to use to move left and right with the camera. I have not (yet) moved to a head tracker, but if you already have that setup, just assign the channels accordingly.

To install the PI camera, remove the stock plate from the gimbals (for a GoPro), and mount the PI camera as shown in this photo:

3689618926?profile=original

The PI camera case fits very nicely into the slot, and again I used a small piece of velcro to hold it down. You could use a couple of small screws instead if you want a more secure hold.  The two gimbals servos are also shown here. They are simple to install, just follow the Go-Discover instructions.

Here is a front view of the PI camera installed:

3689618962?profile=original

Here is the block diagram describing all the connections:

3689618829?profile=original

Some comments on my previous post suggested that it is possible to eliminate the ethernet switch and serial-to-ethernet converter using the Raspberry PI and a serial port on the PI. I believe this post describes how to talk to the PI via the NavLink, but in this case, I want to use the PI to bridge the connection from the ground station to the APM/PixHawk. Somebody please comment on this if you know more about it.   I believe it would require a TCP/IP to serial link from the PI to the telemetry port on the APM, and some software on the PI to act as the bridge.  The main connection to the ground station is via the Rocket M5 and TCP/IP, not through a telemetry link (900 Mhz or Zigbee like I used on my other models).

Step 5: Getting it all to work with software configuration (the really fun part starts now).

Check out this post on what others have done with streaming and the PI.  My experiments showed that using GStreamer on both the PI and on Windows gives really good results with very low latency, if you use the right parameters. 

Get GStreamer on the PI by following this blog.   This is the same version of GStreamer that I am using on my setup. 

Make sure your PI camera works ok by plugging in the PI to a standard monitor using the HDMI port and follow the instructions on the Raspberry PI website on how to get the camera up and running (without GStreamer).  Once you have a working PI and camera, you can then proceed to stream things over the network.  

Note: It is suggested that you first get the PI streaming video by plugging it directly into your local network where you can also connect your ground station PC with the correct IP addresses (without the Rocket M5).   For my PI, I picked 192.168.1.2,  and for the ground station, 192.168.1.1.    Make sure you can ping the PI from your PC and the PC from the PI.  

For streaming, you will also have to make sure all the ports you intent to use are open on the firewall (described later).

For the ground station PC,  you can download GStreamer here.  Make sure when you install, select to install everything , or full installation (not the default). 

Here is the command I use for the PI to pipe the camera output to GStreamer:

raspivid -t 0 -w 1280 -h 720 -fps 30 -b 1700000 -o - | gst-launch1.0 -v fdsrc ! h264parse config-interval=1 ! rtph264pay ! udpsink host = 192.168.1.1 port= 9000

The command is explained as follows:

raspivid is the command to start the camera capture on the PI.  The -w switch is for the width in pixels, and the -h switch is for the height.  In this case, I am using 1280 X 720, but you can try any combination that fits your needs. 

The -b switch is the bit rate for the sampling. In this case I chose 1.7mbs to send over the stream. Again you can experiment with higher or lower values. This settings seems to work good for me, and the latency is almost unnoticeable.  

the "-o - |" is piping the output to gstreamer.  Make sure you include the dash before the pipe "|" symbol. 

For the GStreamer command, all the filters are separated with an exclamation point "!", as these are individual drivers that are part of GStreamer.  Since the PI has hardware accelerated video, the output is in a format called "H264", which is a highly-compressed stream. The GStreamer filters are configured to transport the output via a UDP socket connection to the target PC. Notice the 'udpsink' element which specifies the host - in this case your ground station, and the UDP port.  I am using port 9000, but you can use any open port on your system, but be sure to open the firewall or it won't work!  You can also use TCP instead of UDP, but for such a data stream, I chose to use UDP since dropouts are certainly possible, and with UDP this is ok, but with TCP, you could have socket problems and higher latency. 

Note: to get the PI to execute this command on boot, make a shell script with the above command and add it to your local.rc boot sequence. That way when the PI boots, you get the stream without having to log into the PI remotely. 

For the ground station PC, once you have installed GStreamer and opened the correct ports, use this command (from the command prompt) to view the stream:

c:\gstreamer\1.0\x86_64\bin\gst-launch-1.0 udpsrc port=9000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

If all goes well, you should see the PI camera output on your PC screen in a popup window.  For those of you what want to use FPV goggles, you can connect to the HDMI port on your PC to display the output if your goggles support HDMI. 

I have this command in a batch file (with a PAUSE) statement at the end to keep the window open.

WHEW!  If you got this far, you are amazing. 

The last step to complete the build is to connect to the APM from mission planner.  The method I used to connect was to install a utility that converts a TCP connection to a virtual serial port, but I also think that directly connecting the mission planner to the TCP port will also work, however I have not tried it. I will post back later after trying it.

Here is the link to setup the serial to ethernet device to have an IP address and port.

Here is the link to the configuration utility for installing the virtual serial port.   

Once you have a serial connection over TCP/IP working to the APM, you should be able to connect with Mission Planner. On the maiden flight, it worked perfectly, and I didn't see a single drop in the telemetry data or anything noticeable in the video transmission, however my first flight was limited to 2km.

The last step is to connect the Rocket M5 to the Nano M5 and test everything using the OTA (over the air) connection. If all is well, you are ready to fly!  But be careful on your maiden, you just spent $700. 

Finally, here is a photo of my Antenna Tracker with the Nano M5 attached. My next update will include a video of a longer flight.  

3689618942?profile=original

Happy Flying!

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • @Patrick,

    thanks for your answer about C920 camera.

    Do you have any experience with 2.4 ghz?
    I know 2.4 ghz may that interference with many other sources of wifi,
    I want to know, 2.4ghz is suitable for HD video transmission?
    I test the 100mw 2.4ghz router that boost with 2w wifi booster on copter and 1w usb dongle on laptop that used 9DB omni antenna on both, but the effective range limited to about 400 meter,
    so I confused that the limited range related to used 2.4ghz or any other problem such as low quality booster or mismatch impedance between output of router and booster ...

  • @babak_ea,

    I have video with the C920, but on a different copter that does not have a stabilization gimbal so I didn't think the quality was good enough to post.  I use the C920 for FPV, and a GoPro to record on that platform. I may swap them just for fun to see the difference. The C920 is definitely better than the PI camera, so if you want quality video recordings rather than just an FPV experience, the C920 is a better choice.

     

  • @Patrick,  I have clear line of sight for about 340 degrees around the horizon. I live in the country and there are very few trees or buildings.  It's farm land in central Texas.  The 5ghz setup may not be the best choice is congested areas, but for my location it works great. 

    I have experimented with many different configurations, Ubiquity Nano M5, Rocket M5 with custom antennas, and the Nanobeam dish.  By far the dish is the best. The best noise floor I was able to get no the Rocket M5 was about -95dBm.  With the Nanobeam, it's in the -105 to -110dBm, and the gain is 6db higher.  The patch antenna on the Nano M5 is pretty good and allows for a sloppy tracker, (19deg beamwidth), as compared to the dish which has a 10 deg beamwidth.  So far, I have not had any tracker problems with the narrow beam of the dish.

    As far as the cost goes, the Nanobeam is < $100 and the WiFi adapter I am using was $75. (Amped Wireless ACA1).  I have found that the Netis WF2561 is also as good and smaller and lighter, and a bit less expensive. The tracker I built cost around $300, so total investment (not counting time to build), is < $500.  Compare that to the commercial solutions that do longer range WiFi (thousands), it's not too bad.

     

    I have not tried any geo-stamping on the ground station.  I could add this to the HUD because it already has a connection to the Mavlink stream.

  • Thank you for all the info.

    I guess you are flying in a very uninhabited area to get such a low noise level ?

    Wonder if using a simple python program to compare the onboard GPS Timestamp as UDP mavlink packet transmitted through the WIFI and a second  GPS Timestamp running on the ground station could work.

    mavlink_msg_gps_raw_int.h : time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/

    BTW I am running BBB + ErleBrain 1 +Logitech C170 +  MJPG Streamer over wifi using Realtek 802.11a + circular polarized FPV type antenna + Tracking unit with 14DBI patch + Realtek to USB on the Laptop. 

    But I never achieved such high quality , with no jitter and apparently low latency as your setup. Might need to spend a little more money :-))))....  

    Regards

     

     

  • @Patrick, very cool,do you have any video with C920 camera?

  • @Patrick, during the test flights I monitor the traffic using the Ubiquity tools to track the signal strength in dBm received from the remote. I don't have a way to monitor the uplink yet, just the downlink.  I have not logged the glitch/packet loss yet. Maybe on the next flight. 

    There is no change in latency that I can notice, but I have not measured, just observed from my controls. With the flight shown, the signal strength never fell below -75dBm, with the noise floor at -105 so the margin was still well above the noise floor and there was no noticeable dropouts or delays. 

    Using a similar setup in a fixed-wing, I did some tests out to 11.5km a few weeks back and the signal strength at the limit was about -85dBm, still well above the noise floor. I think 15km is easily do-able without any mods. 

    I am doing some experiments with different antennas to see if I can improve the performance by changing the position and type. Here is a picture of my first test configuration using two skew-planar wheel antennas (RHCP/LHCP pair), mounted to the arms of the copter, hanging below. This is the setup I used to record the video.

    3702132793?profile=original 

     

  • Amazing !!

    Did you check on the stats on the Ubiquity or Netstat for any kind of glitch (packet lost, resend, and so on)?

    What level of RSSI (Or SNR) can you achieve at 4 km whit this setup ?

    Did you experienced any degradation on the latency during the fly ?

    Keep on !!

  • I decided to post a video from the 3-d printed quad I just built. This is a 4 mile flight test recording on the ground using the GStreamer HUD. https://youtu.be/UNXysQH767s

    Ground station uses Ubiquity Nanobeam dish 24dbi gain mounted to a tracker. UAV has an 'Amped Wireless ACA1, 500mW 5.8Ghz WiFi.  Range is farther than the video shows, but for multi-rotors, it's pretty good.

     

  • @Patick, Thank's again for your useful post.

  • Patrick, thanks a million!!!!!!!!!!!!

    I have been resetting the m5 since morning, really struggling,

    on the meantime FYI I have working on the pi the following:

    edimax ew-7811DAC 5ghz
    tp-link T4UH 5ghz

    Again many thanks

This reply was deleted.