I've got the basic attitude estimator running. The Pitch and Roll drift is being corrected by the accelerometers, but I still need to use the magnetometers and/or GPS to correct the Yaw drift. The yaw drift is actually very small as you can see in the video.


Views: 2744

Comment by John_Mac on May 23, 2009 at 12:31pm

Very impressive.

I have coded something similar to your display in Visual Basic (but probably much slower), but can you tell me what application you are using to display? This is a nice test station to check things out.


Comment by Brian Wolfe on May 23, 2009 at 3:24pm
Hey John,
It's developed with Python. I've heard of Python for years but never really looked into it, but when I saw the reference to it on one of Louis LeGrand's posts I decided to jump in. He was nice enough to share his script which I then modified to match my hardware configuration and display the axis.
You'll need to install Python as well as the VPython, pyserial and pywin extensions (assuming your on a windows platform).

Once you've done that you can run this scriptdemo.py

The script reads the data in via a serial port so you might need to edit it to point to the appropriate com port.

It's easy to get going, so jump in!!

Comment by Earl on May 27, 2009 at 10:09pm
I use Labview for my GS. Data sent via XBee radio and video on 900mhz with overlay data. Your welcome to use it as I was inspired by Chris Anderson and Jordy. They won the Sparkfun autonomous competition 4/15/90. The Sparkfun 6DOF is reasonably priced at $124 and has a simple serial output. My whole system is working good now as far as the sensord, video with overlay, and GS 2 way data to the wing. This is fun for an old retired goat like me.
Comment by Patrick on February 7, 2010 at 1:21am
Hi Brian,
I want to thank you for being so generous by sharing your knowledge with all of us. I have learned so much by reading your blog.
I have a question about the exact format that the serial data needs to be in to work with the demo.py file that you have posted. I have the demo loaded up in python and I am trying to get it to work with my new 9DOF IMU from sparkfun. What format does my serial code coming from my IMU need to be in to supply the correct values for your code to read? Right now I am just using the stock firmware that the IMU shipped with, which outputs the data like: X=180,Y=180,Z=180.
Do I output it like:
with a carriage return after each line?

What does rmat refer to? Does the value 32767 refer to the baud rate, or something else?

Thank you very much for any help you can give me, and keep up the great work!

Comment by Brian Wolfe on February 16, 2010 at 8:07pm
Sorry for the delay in getting back to you, I only just noticed your post.
It's been awhile since I used the Python script so hopefully I can remember the details.

You would send

row1: val[0][0] val[0][1] val [0][2]
row2: val[1][0] val[1][1] val [1][2]
row3: val[2][0] val[2][1] val [2][2]

with a line feed ( \n or ASCII 0x0A) after each line.

The rmat just stands for rotation matrix. It's just to let the script know what data is
coming. You could certainly streamline things and get rid of it if you wanted. On a later
version of the script I also sent some magnetic vectors, so a header on each data group
just made it a little easier to keep things organized.

As far as the 32768, since I'm using a 32 bit integer processor most of my internal variables
are represent in fixed point (18.14). The data is sent to the Python script as a 32 bit integer
and by dividing it by 32767 it is converted back to the appropriate floating point value. In the
case of the DCM, a value between +/- 1.

Let me know if that answers your questions.

Comment by Patrick on February 16, 2010 at 9:09pm
Thanks a lot for taking the time to reply...that answers all my questions perfectly.

I have created a flight center in Flash that reads the serial data from the sparkfun 9DOF imu (converted to AHRS) and displays it on an artificial horizon complete with heading, pitch, and roll. It makes it easy to connect to the aircraft over XBee and monitor data in real time. It includes battery monitoring, airspeed, altitude, etc and can also send commands (launch the parachute!!) to a microcontroller on the aircraft. I will post a link to the code for anyone who wants a copy once I get it completely debugged. Thanks again.
Comment by Jesmond Gatt on July 4, 2010 at 7:58am
Hi, do you have the pc software to make the board rotate? if yes could you please upload it.Regards
Comment by oliver Grant on December 9, 2010 at 3:26pm
Hi Brian,
fantastic project. By far one of the best I have seen. Will keep an eye our for you gerbers!!
I'm doing a postgraduate degree in controls engineering at the moment and I'm looking for something to tinker with on the 'rainy days'. let me know if there is something I can do to contribute. In fact, your board design would look great on my soon to be purchased heli (TREX600..)

keep us posted
Comment by Alessandro Zupo on October 22, 2013 at 11:18am

I had just did a complete quadcopter with pic32mx Architecture ;)


Whit USB HID interface i'm able to see at 200Hz realtime the raw data and filtered data.

Unfortunately....two days ago i lost my quadcopter ...because was without magnetometer and  GPS.... :-((

So know i would like to study the alghoritm for Altitude PID e GPS hold.....some people know that??

Comment by oliver Grant on October 22, 2013 at 12:07pm

Hey Alessandro,

 Looks great! I ended up purchasing a compass 6hv. unfortunatly, its still sitting gathering dust in the corner of my room along with my PIC32 starter boards.. : /

I cant help you on the hardware side but if you're interested in looking into controls and can beg or borrow a copy of matlab I would start here - http://www.mathworks.com/discovery/pid-control.html.

Just had a quick skim and there is a simulink quadrotor model here - http://www.mathworks.com/matlabcentral/linkexchange/links/2961-robo...



You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service