Saturday, September 13, 2014

My UAV Project: Part 4



Having Some Fun

In my last post, I detailed all of the trials and tribulations I had while trying to get the flight code operational on a puny Atmel328P. I decided I had labored without results for a while and earned some fun time, so I started working on the mobile app. That and I started picking up PCB layout skills. I've also been reading through some college texts on Dynamics and Control. It's been an awesome couple of months.

Oh, and I'm still flying kites! (Be sure to watch in 1080p)

The Transponder Setup

The goal was originally to have a transponder in my harness that could radio my location and some small configuration to the drone. I decided that this wasn't enough, so I extended the transponder by making it an intermediary that would provide location and also act as a repeater. The setup is seen below:



In essence, I wanted to have a mobile app connect to the transponder via Bluetooth, send commands via the mobile app, and have them relayed to the quad via the transponder. The transponder would also provide high quality GPS and altitude data.

iPhone? iMpossible

Having been slowly drawn into the world of Apple fanboy-ism, I decided to further ingratiate myself into their ranks by choosing iOS as my mobile app platform. You can imagine then my horror when I found that Bluetooth wasn't easily & readily a supported development platform. As it turns out, only Bluetooth 4.0+ (the low energy variety) is supported, and that's done via the CoreBluetooth library.

I had already purchased a 2.1 Bluetooth module at Fry's and wasn't interested in buying something else. As such I turned to the internet and quickly found a few solutions. The private API seemed like a great way to go and seemed to have everything I needed. I didn't want to submit this app to the AppStore, so there was no concern with using a private API.

There was, however, a huge issue with this article! I downloaded headers. I got my project set up. I debugged my code all the way to pairing my phone & the device before realizing the article simply ended after pairing... There were no instructions on how to send and receive data. I then checked around the internet and found that this is simply an unknown facet of this particular private API. Perhaps I was completely oblivious to some well known iOS fact, or perhaps I'm not well versed in some other libraries, but I'm pretty sure this feature is just completely missing or unknown to those outside Apple.

Official iPhone Solutions are Expensive

I did look at the official, legal route to get iOS working in my system. First I would have to save up, incorporate, and purchase an MFi license ($$$$) for my supposed shell corporation. This would allow me to purchase an authentication coprocessor($$$) from Apple, which I could then use with a similar but entirely different Bluetooth module! (the RN42-APL... $$$) With these constraints satisfied and Apple's coffers thoroughly stuffed, Apple would finally grant me access to use their BluetoothLibrary. Clearly things weren't looking great for my bank account (or iPhone), so I decided to abandon this path.

Android is Less Ridiculous

Seeing as how I had an old HTC One S lying around, I figured I'd give Android a quick look over. As it turns out, the documentation is very clear and getting Bluetooth up and running was a snap. There were source examples among other things to help speed up my hello world app. In no time at all I was pretty easily pairing, communicating, and running a simple parrot app. Android is a really interesting platform. Its execution environment is (fortunately) well documented, and seems plenty similar but plenty different from iOS. I'll want to expand on this in a later post, I imagine.

Mobile App Outcome

Getting an E2E signal is always one of my first goals in these sorts of embedded projects, so I'm very happy to report that I'm able to connect to the quad and blink an LED from my phone! (Blinking LEDs, always a great first step!) However, now that the number of entry points to the quad is increasing, I need an IDL && an accompanying schema compiler of some sort so that I can easily share the protocol across different stacks. There are many different solutions, each with its own merits. I'm not too concerned with inheritance or extensibility, so most of them would probably work provided they target my languages and platforms. I'll need to put some energy into this soon.

More Hardware!

I'm slowly picking up small sub-projects to get better at using the tools at the nearby Metrix Create Space. I recently participated in a Sunday night circuit hack night called Circuit Church. Below you can see the circuits/layouts a coworker and I designed one night a month back:



I did my work in Upverter, a circuit design and PCB layout tool. It's a great tool, and I plan on doing another layout soon so that I can have a dedicated, custom shield for all of the sensors/motors/radios that I need for the quad. Basically I want to get rid of this mess:



Note that the GPS, altimeter, and magnetometer aren't even in that picture!

Studies - Dynamics and Controls

I decided a few months back that having a better theoretical understanding of controls would help tremendously in shaping the coding and design choices I'd make going forward. I commend myself for jumping into this project and getting a basic PID loop operable, but I feel like I'd spin my wheels too much if I kept up this approach of learn-theory-by-hacking. I have time and don't mind doing the math! That's why I picked up and have been enjoying these two beauties since then:



(Sorry Dylan! Our alma mater's Controls text didn't align with MIT OCW!)

I've made surprising progress through both books and will keep heads down until I get through the syllabi I found on MIT OCW.

The Sky Ahead

I'll try to jump back into getting the Math working on the flight computer. I have a quaternion library on my laptop that I want to use in attitude estimation. I'd also like to simulate 32 bit computations to see how the quaternion replacement for the DCM estimation filter handles tiny floating point errors. If the errors are minimal, I'll port the quaternion library to the flight computer and call it a blog entry! Otherwise I'll probably need to make a board for my FPU coprocessor, integrate it with my flight computer stack, and write double-double arithmetic so I can support the on-board computations at higher precision. I also want to keep reading up on theory and hacking on the android app as necessary. Should be a fun couple of months ahead!

Hard to think I started this project nearly a year ago. It's been quite fruitful and a lot of fun! Thanks for reading!