This will be my first post here. Just sharing what I've been up to, and sort of documenting what I've done (particularly in the case that I have to back up a couple of steps and retrace them). I realize that I'm not the first to do a wifi based link, but I intend to document it well!
I've built a few multicopters with the DJI Naza. My first was a quad, which flew wonderfully until it lost a prop and fell out of the sky. My second was a flat hexcopter, which flew even better, until a battery puked midflight causing a bit of a rough dirt landing.
So now I have a list of "must have" items for my next build (which will salvage many of the parts from the prior two).
- Motor redundancy (Y6 configuration with Pixhawk oughta do it)
- GOOD telemetry. The OSD displaying voltage of a single cell didn't cut it. Pixhawk should have me covered there.
- Redundant bingo battery. I will have this switched in via relay whenever I (or the Pixhawk) commands RTL. Should ensure I get home no matter what... provided both batteries don't puke at the same time... :S
That's all well and good. But if I am going to rebuild, I might as well add some "like to have" features in there also. I've always been a bit disappointed in the quality of the analog video transmitters we use. They do their job just fine, but they are limited to 640 x 480, tend to be susceptible to interference, and require additional hardware to get the video to show up on the laptop I intend to use for a ground station.
In addition, my particular aircraft carry a 50 watt sound system for use at Burning Man. Long story there... :D Getting audio UP to the aircraft has been a challenge for me, I've tried both walkie talkies as well as an FM radio transmitter. Bleh. I needed a better way to do that as well, though this feature probably doesn't apply to everyone ;)
So long story short(er), I decided to use a Raspberry Pi computer with a camera module and a wifi adapter to connect to a laptop. The goal being to stream HD video to the laptop in real time. This has an added bonus as I can stream audio UP to the craft without pesky, noisy analog transmitters. I still needed telemetry, however.
Originally I wanted to use usbip to connect the Pixhawk virtually over the wifi network via USB, but both usbip and a similar program called USB-redirector have much difficulty installing properly on the Raspberry Pi. Those that have reported getting it to work are reporting somewhat frequent crashes, though some of that MIGHT be attributed to the Pi being very finicky about how much power it is getting (plugging in one extra usb device sometimes will cause a lockup or crash without proper power).
Luckily, the telemetry port on the Pixhawk is a simple serial I/O port! There's a very small and simple program called ser2net that allows the Raspberry Pi to share a serial port over TCP/IP. I could either use a USB to serial adapter, or use the built-in serial port on the Pi's GPIO connector. I chose the latter. After changing a few files to force the Pi to let go of it's serial port (ttyAMA0) I was able to assign it to a port on my wifi network. APM Planner 2 allows me to connect directly to this TCP port, and voila, telemetry over wifi.
Of course, this is all well and good, but how far out can I go? Most wifi only goes a couple hundred feet at best... going farther would surely break the bank, right?
I am happy to say that the answer is "NO!" Using a "Gemini Doctor 48db" (same as "Signal King 48db") adapter on the ground, and an ALFA awus036NHA on the "Pi in the sky" I was able to stream 25 fps video approximately 1/2 mile along the ground, using my hand as a crude gimbal pointing back at the house. My adapters were set at 800mw at most, but likely (due to Ubuntu) I was transmitting from the laptop at only 200mw. Either way it worked fine. I purposely "broke the link" by pointing the patch antenna away and back towards the house a couple of times. Everything synced back up nicely. In addition, the camera software allows me to capture 5mp still images, or record HD video onto the SD card on the Pi with a click of a button, and download to the laptop as well. Good stuff!
So what's the total cost?
- Raspberry Pi $25 (donated by my uncle, so free for me :D)
- Camera module $35 (also donated!)
- ALFA awus036NHA $30 (sometimes they sell for $60. Other adapters may work as well, but the ALFA awus036NHR V.2 is a BIG NONO. Won't connect reliably on the Pi, but works great on my windows box... go figure...)
- "Gemini Doctor Signal King" whatever adapter. $20. That's right. 20 bucks.
Total? $110. Less than most folks spend on an analog setup. I spent more on a fancy case for the Pi, and experimenting with the awus036NHR V.2. The system isn't very heavy, either. The Pi supposedly weighs 45 grams. The adapter is about the same. Camera module can't be more than 15 grams. And the other wifi adapter is on the ground so who cares XD
The real cost though, is grinding through getting everything to work properly. This was a huge trial and error process, and I'm happy to let everyone know what does and most certainly does NOT work. (speaking of, the awus036NHR V.2 doesn't provide a wifi hotspot in Linux either, so one can't even use it on the ground unless you have Win 7 or higher D:).
Things I still need to do:
The program I'm using to stream video is called RPi_Cam_Web_Interface. It is capable of streaming 1080p HD, but requires a larger browser window to do so. I have mine set to whatever the standard setting is right now, so I can tile the window along with APM planner for the viewing of telemetry and video on one window. It still records in HD and takes good pictures though :) No sense streaming full HD if I have to shrink the window in the end anyhow.
I'd like to develop a widget for APM planner to open a browser window inside of APM planner. That would be better than switching back and forth between APM planner and Firefox.
I need a tracking antenna. I've not gotten to the point of implementation yet. I can always hand-point the antenna in the direction I wish to fly (it has 2 omni antennas for up close - pretty sweet for 20 bucks). I'd prefer an ardupilot with GPS mounted on the back, and a winch servo to rotate past 360, and everything to automatically configure itself so my antenna happily points at my aircraft. A guy can dream....
I still.. um... need to build the actual aircraft. I have spent the past month getting the datalink to do ALL the things that I want it to do. I have enough parts to build a couple of multirotors, the issue was I plan to build this frame entirely around this datalink. I just didn't want to start until I got a proper range test. The pictures below are of prior multicopters.
Camera lenses. I'm going to mount a few cell phone lenses on a disk and use a servo to position them in front of the Pi camera. This will all be mounted in a tic-tac box. Mmmm fresh breath. :D
Portable GCS. I have a large toolbox that I can put everything inside. I plan to build a charging station, 12v and 120v in and out (for solar and shore charging and laptop power). It currently holds my flat hex, and a computer monitor adapted to receive analog video.
That's all I have for right now I think... I'll post more as I start the build.
(old photos below)
Replies
Hi there,
Wow, it's been awhile since I've worked on this - and due to some issues with the firmware way back then I grounded that aircraft o.O
As for the code - I'm trying to remember. I used RPi Cam Web interface for the HD streaming and I can't remember what I used for a TCP serial port - but it was a fairly common and easy to install program.
Everything else was fairly stock since the ground station is capable of looking for telemetry via a TCP connection, I just configured it. And on my laptop I visited the website generated by the Cam Web Interface. Everything would be so out of date right now though and it would be likely that the versions I used have been updated - maybe I'll rebuild it someday with the C model!
I really admire people working on raspberry pi. I have done a similar project based on ardupilot.org/. The raspberry pi is so easily available with plenty of community support. can u please share the rapberry pi code on this blog. I would love to try wifi adapters mentioned by you since they are very cost effective.
Hi Ryan , i want to setup a similar link can you help me out ? Can you ping me your mail ID :)
Guy im building the same exact setup as you have, except I don't have speakers on my hex, looks really interesting I might even have future question on how to setup the pi
Nice! Feel free to ask if you have any questions. Right now I'm having issues with getting servo passthrough to work with the autopilot, but I plan to hit it hard this evening. Also my telemetry didn't work with Mission Planner on windows, but works fine with APM Planner on Linux. I'm not sure why this is the case, but if you have a windows based ground station you may wind up with some headaches :)
Finally got to fly! The video is here:
https://www.youtube.com/watch?v=tCg9ruTLPEM&feature=share&li...
I didn't get any shots of the laptop unfortunately, and I didn't get to watch the video on the screen myself, though Jasmine and Scott reported it was just fine. I did want to cycle the lens turret, but that will have to wait. I would prefer to get the gains set properly before that.
Also I solved my telemetry issue. Had "XONXOFF" instead of "-XONXOFF" in my config file. Oops o.O
Telemetry works perfect now!
Started the build. Going to begin the payload box tonight as the frame is mostly done. My entire payload has previously been gimballed only on the pitch axis, and I'll probably keep it this way for the time being. Considering using plastic chain to drive it, so that my 180 degree servo can drive it and stabilize it when it points straight down.
My camera lenses have not arrived yet, hoping they will be there tonight so I can set up the camera. Vertical view fisheye would be pretty neat I think :) Plus I can capture 5mp images in the air, so I'll be able to make use of the lenses I think. Will have to isolate the camera from vibration though for sure.
I'm leaning towards just using two batteries in parallel and skipping the whole "switch" thing. I'll just have to keep checking the battery status. Maybe program a "beep" every 2 minutes...
I've gotta dig out my castle link so I can reprogram my CCBEC to provide a good 5V for the USB though. The Pi, the adapter, and the camera require a good power source or things start to hiccup.
A picture so far is below:
More building pics.