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

  • For sure it works !!!

    My WISP business is running on a mix of Motorola Canopy and Ubiquity. Never though I would fly one though... :-)

  • @Patrick, I have not tried WiFi broadcast because I don't think the Ubiquty hardware supports it out of the box without hacking the firmware. Their firmware is much more forgiving than standard wifi dongles when it comes to dropped connections though. I have had it drop the connection, but it usually is able to recover.   These long-range WiFi units are designed to handle drops better than standard wifi because they have to work over many km.   I am also using UDP for video, and I am not an expert on protocol, but I don't think it verifies each packet is transmitted with UDP. I am not sure it's exactly the same as wifi broadcast, but it seems to work on my setup.

     

     

  • @babak_ea,  For analog video, I think you can get away with that setup.

  • Hey Patrick

    To make sure that the Frequency Hopping do no t interfere in the 2,4 Ghz , here is a hack, that I qualify as ''expert level'':

    https://befinitiv.wordpress.com/2015/08/26/enable-2-4ghz-rc-systems...

    Naturally it only apply if your transmitter has the TI CC2500, but it is technically very interesting project.

    BTW did you ever experienced with WifiBroadcast ?

    Enable 2.4GHz RC systems to work with 2.4GHz video systems
    This post shows how to modify most 2.4GHz RC systems so that they won’t interfere anymore with 2.4GHz video transmission systems. — Introduction Ever…
  • @patrick, 

    according to My previous experience for analog video link, I could get 5 km range and good video quality with 5.8ghz ,2w boscam transmitter that used cloverleaf antenna on copter and homemade Ibcrazy 6 turn (10dbi) helical on receiver without tracker and I Have not any issue because it has 55 degree field of view.
    but in your project I think that need more gain on receiver antenna. so I Build your antenna tracker soon as possible.

  • @babak_ea,  my last note was only considering the uplink power.  You would end up needing the 15watt amp on both the ground and UAV to make it have the same range because you get gain on the receiver and the transmitter on the ground when using the dish, but not with the Omnidirectional antennas. You are focusing the uplink beam at the UAV and also gaining up the signal from the UAV by the same 25dbi, you can't compensate for this gain difference with a bigger RF amp. It's just too much power and the size is not practical.

     

  • @Patrick,  there could be some interference with the 2.4ghz control radio, but since the radio channel-hops, it should pick a clear channel, but in congested areas it could be an issue. It is another reason to pick 5.8ghz.

    @babak_ea,  the bandwidth is not an issue if you are using H264, which I assuming you are if you have a C920. I think on my system the bitrate is < 10mbs at full HD.  There is something else limiting your range. You can always

    crank more power to get better range, but it's inefficient to do this omnidirectional. 

    If you do the math, it becomes quickly obvious why. For example, to get an equal power level to a 25dBi dish using a 9dbi dipole, you need an additional 16dB gain. Say you are transmitting at 2watts (33dbm), into a 9dbi Omni, with a VSWR of 2,  that's 39 dBm RF power effective.    For the Nanobeam, it has 27dBm power + 25dbi gain, and assuming similar VSWR, that's about 49dBm effective RF power.  For your 9dbi antenna to make the same power, you need 15 watts of RF power at the antenna!  That's a HUGE amp.  I happen to work for a company that makes RF amps, and a watt amp that covers that frequency range cost about $2000, and you need a HUGE heat sink!    So the lesson is, get a directional antenna. It's the only way to really increase the range.

    Have you considered using a tracker?

  • @Patrick Poirier, I Use 433 Mhz radio link.
    @Patrick,
    no I'm not flying with a lot of sources is that frequency range.
    I know about high frequency properties and antenna importance, but I don't know that 2.4 ghz does enough bandwidth for HD video and telemetry transmission with good Rf power?
    Sorry for my Bad English.

  • If I may add : The basic fact the most rc transmitters are now on 2,4 Ghz.

    Unless you have a 72 Mhz old scool type, it may be quite complicated to run both system simultaneously.

  • @babak_ea,  In theory, 2.4ghz could range just as far, if not farther except for the possibility of interference. 2.4ghz is certainly more crowded because of standard WiFi that could interfere, and that could limit your range. Are you flying with a lot of sources is that frequency range? 

    The biggest factor to really extend the range is to use a directional antenna with a tracker, and higher quality antennas on the UAV. Impedance mismatches can kill the performance if you use cheap antennas.

    The narrower the beam, the farther you can transmit/receive. Directional antennas also limits noise sources from other directions so you get an improvement in both noise and gain. Multi-path interference is also all but eliminated using a dish, as you get a large rejection from multi-path sources. The reason I picked 5ghz was to limit the size of the dish and the antennas on the UAV.    It's quite manageable to mount the Nanobeam on a simple geared servo without having to worry about weight.  Here's a picture:

    3702093533?profile=original

     

This reply was deleted.