Goals and First Start

I thought I'd start out by outlining the goals of this project. Several years ago, I bought a remote control helicopter from Hong Kong, it's a Walkera Dragonfly fixed pitch helicopter (pretty much identical to the E-Sky Honey Bee Micro, or the Twister). It was pretty difficult to fly, and almost impossible if there was any wind. After I started getting into microcontrollers and control systems at uni (I'm now in the final year of an Elec engineering and Comp Science double degree), I started playing around with an Arduino and after awhile decided that I'd like to build a PID (or LQR) stabilization controller for my helicopter to make it easier to fly if I ever had the time (and then evolve into full automation if I can). This was a year ago, and in the mean time I haven't really had time to do much about it. Now it seems I finally have time (or, at least, the willpower to make time for it).I already had an Arduino Duemilanove, so I bought my first sensors a couple of months ago when I was all cashed up. I got these:ArduIMU Main board (4 DOF with room for 2 more gyros)http://www.sparkfun.com/commerce/product_info.php?products_id=93722x ArduIMU Daughter boardshttp://www.sparkfun.com/commerce/product_info.php?products_id=9373I got these about a week later, and assembled them no problems. I was surprised just how small the unit was. I managed to do some basic coding (getting the values from the Arduino to serial) but decided to save the rest for the summer uni break.Fastforward to now: I started working on it again about a week ago, and due to full-time work experience I only really have evenings with which to chip away at this project. I've got the sensors connected to the Arduino and I'm scaling the ADC values to units of gravity and degrees/sec, then calculating the gyro angle (in radians) through integration and acceleration angle using arctan2.Here's the setup:

Then I recorded a sample, rolling right & left then pitching down and up and yawing right then left. The X-axis is time in seconds.

As you can see, there is quite a bit of drift on the gyros, so I'm going to implement a Kalman filter to hopefully eliminate this.
E-mail me when people leave their comments –

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

Join diydrones


  • Hey Doug, I'm aware of DCM but haven't really delved into it much yet (wanted to try the Kalman first). The code of Jordi's that I was referring to was his earlier work with the first ArduIMU, he implemented a Kalman filter on that before moving onto DCM. The code can be found here: http://diydrones.com/profiles/blogs/705844:BlogPost:23188
  • Developer
    @Jason - Jordi's code is not a Kalman filter, but an implementation of the DCM algorithm by Premerllani, Mahoney, etc. That would explain why the variable names don't match any of the Kalman filter theory you are reading :) If you look at Bill Premerllani's paper the variables will make sense.
  • Chris, I've been following your work with the ArduIMU (and kind of kicking myself that I didn't just wait a little longer to buy my sensors and just buy the v2 flat instead), and you guys are doing some great work. For the benefit of my own understanding I'm having a crack at it myself using as many resources as I can find. I've been looking at Jordi's kalman filtering code, but the variable names he uses are different from what I've been reading about (in Kalman theory), so I'm trying to go from scratch to glean more understanding.

    dp, this is just some basic testing to look at my sensor measurements and gauge the average noise and whatnot. I was just planning on plugging these values straight into my Kalman filter, and I'm not sure what you mean by quaternions.

    Mike, this is just the readings from the sensors in the arrangement you see in the first photo, I'm just tilting it by hand. I'm almost positive that my helicopter won't be able to lift this setup (haven't been game to test yet), but I do have an Arduino Mini (also known as the Arduino Stamp - http://www.sparkfun.com/commerce/product_info.php?products_id=8164) that I'm hoping isn't too heavy if I hook it all up on a small bit of vero-board. If I do add GPS later on, that might tip the scales too heavy though :(
  • Jason you didn't say if the readings were from the unit when mounted on the heli? Although I do have a honeybee and the electronics you have put together look a bit heavy as a payload - it struggles to lift itself!

  • Great works! But I do not understand why do you calculating the gyro angle (in radians) through integration? Why not quaternions ? Are you just test your circuits?
  • 3D Robotics
    Hi Jason,

    Great start! But out of curiosity, why are you coding your own filter? We've already done all that for you with the ArduIMU code.
This reply was deleted.