Head-Tracker Controlled UAV Video Payload

Screencast

Uploaded by k4fly on 2011-05-23.

Source Code

https://github.com/delacruz/headtracker

Why

I've spent the last few years of my career working in the aerospace defense, specifically in unmanned aviation. This career path was no coincidence; I'm a huge fan of aviation (RC too!) and a computer geek, so the UAV field seemed like the perfect marriage! I recently decided to create a low cost pan and tilt camera system with head-tracker for use in my own home-brew UAV project! In this post I'll describe the setup I've assembled for this purpose.

Objectives

Below is are a few key matters I kept in mind while working on this project...

  • Low cost. Most of us can't afford a million dollar payload like those on the Predator or Shadow 200. At the same time, I didn't want to sacrifice quality too much - after all, I wanted this thing to be useful. I aimed for under $500 while maximizing reuse of a few items I already had in stock from previous projects.

  • Head Tracker. For me, the ideal system to provide an immersive experience by virtually embedding the payload operator into the air vehicle. This meant that the operator would need to wear some form of head-mounted-display. I've opted for video goggles (yet to acquire) along with sensors monitoring the operator's head pitch and heading. This sensor data would then be included in the air vehicle uplink data packets.

  • Independent Datastream. Several solutions exist where some pan and tilt servo commands are fed into a Futaba controller input; this type of solution was not an option: I wanted a system where I had better control of the uplink packets, giving me the ability to expand upon my initial design. The datastream needs to support additional commands such as autopilot waypoints for autonomous flight. Ultimately this meant that I would have to route my data thru some form of ground control station (GCS), and uplinked via some wireless data modem. I chose the Mac platform: why? Well, simply because I want to learn my objective-c and cocoa, and I had the liberty to do so!

Parts

  • Digi Xtend 900MHz 1Watt Serial Modems

  • 900MHz 500mW Analog Video Transmitter

  • OceanServer OS5000-US 3-Axis Digital Compass

  • Robostix (ATMega128)

  • Dimension Engineering BattleSwich 10A Relay

  • Dimension Engineering Adjustable Stepdown Voltage Regulator

  • KT&C CCTV Color Video Camera

  • 900MHz Dual Output Analog Video Receiver

  • XLR8 XtraView USB Video Capture Dongle

  • 2 x Hitec Servos (one modified for 180deg rotation)

  • ServoCity Pan & Tilt Servo Assembly

  • RC Receiver (+-s) Jumper (For monitoring failsafe mode in case of controller signal loss)

  • 11.1v LiPo Battery

  • Plexiglass, spacers, screws for temporary stacking of the hardware

Pan & Tilt System Power Distribution

The video camera and video transmitter both require 12v to operate (11.1v do just fine), and the rest of the components require 5v. I used an adjustable voltage regulator to step down the voltage to 5v where needed. I also used a master relay to swtich the camera and video transmitter on and off as needed, both draw a significant amount of current. Using a relay would allow me to power on the video subsystem only when needed, maximizing my battery life. The relay is controlled by a PWM pin on the Robostix. The high-level power distribution is illustrated below.

Power Distribution

Power Distribution

Code and Challenges!

Below are some of the challenges I ran into and how I went about resolving them. I won't describe the actual code in too much detail, but the source is commented well and available on github at https://github.com/delacruz/headtracker, feel free to contact me via email with any questions.

Ground Control Station

I chose to write the GCS in C and Objective-C for the Mac platform. The decision was based purely on me wanting to learn programming for the Mac platform. The beginnings of a ground station were pretty simple to develop. I naively intended to use my Elgato USB capture device so I could embed a video output windows onto my GCS - I quickly hit a wall as you cannot use it as a quicktime capture device, in other words, you can't programmatically access it in any useful way. Hopefully this will change one day, perhaps Elgato will release some library that will allow you to program for the device. This didn't discourage me from writing the GCS for OSX, I did some research and found what appears to be the only usb video capture dongle that will show up as a quicktime capture device: the Daystar XLR8 XtraView.

Robostix

Assembly, or C? I elected to write the microcontroller code in C (using AVR Libc), I felt this would allow me to develop a lot faster. Development was a bit slow nonetheless as debugging is a always a bit trickier without additional tools like a JTAG; I was limited to debugging via blinking LEDs or printing strings out a UART. It should be noted the Robostix is something I already had in stock, were I to do the project over I would prefer to use an Arduino! Unlike the Arduino, programming the Robostix will require you to use some type of EEPROM and flash programmer, I used the AVRISP mkII. I spent a great amount of time setting up a development environment in Mac OSX before learning about the AVR CrossPack, so please save yourself a lot of time and download that first!

Datalink

This was my first time working with the Digi 9xtend wireless serial modems. I was pretty impressed with their performance as far as speed and reliability!

I did encounter one problem with the OEM Module operating in "Binary Mode". Binary Mode allows you to set a pin to high, immediately giving you access to query modem data. So say you uplink packets at 10Hz, and every couple of seconds you wish to obtain query the modem to find out it's Rx signal strength, change it's power output, get information on dropped frames, etc, you'll need to enter this Binary Mode so that data sent to the modem gets handled as commands instead of being transmitted over the air. The problem I ran into occurs most often when uplinking data at faster frame rates, ie. 30Hz and up. On occasion, the modem transmitted one or two bytes it should have handled as commands. I spent a few days troubleshooting this issue and was unable to resolve it; I'm inclined to believe this may be a genuine bug in the modem's firmware. This may merit some further investigation.

I purchased these modems a few years ago as a developer's kit. Included were a couple of development boards, two OEM RF modules, a few antennas and a variety of accessories. In the air vehicle module, the OEM modem is used without a development board, this means you communicate with it at TTL level, which of course if convenient since you're interfacing with microcontroller's UART. However, in order to do so, you need to obtain a female socket for the OEM RF module, which surprisingly Digi does not carry! Luckily, this was no problem - Sparkfun carries a breakout board and a the socket connectors for the xtend modems!

Lessons Learned

  • 5v Video Tx and Camera! You can spare yourself parts and complexity by finding a 5v Camera and video transmitter. Most users won't need a 500mW transmitter, instead invest a decent patch antenna and you'll be able to achieve excellent range with only 100mW! Also, using smaller CCD 5v camera is guaranteed to give you better battery life if you wish to fly with a smaller LiPo! I do recommend a wide angle lens.

  • Go Arduino! With a Arduino, you hit the ground running! Some of the benefits:

    • Easy: IDE installation is a breeze. Once installed you've got all the tools you need to write code for your Arduino's processor!

    • No separate in-system programmer needed! That is a huge plus. It also means you don't need a usb-serial converter if you have a newer machine without a serial port.

    • One cable to rule them all: The Arduino is programmed via a USB cable. It is also powered by that same USB cable, and your UART0 communicates via that same USB cable! Believe me, this saves you the headache of dealing with lots of wires! This alone is pricesless!

    • Resources: Arduino is and has been hot stuff for a few years. There is an enourmous wealth of information on just about anything you can wish to do!