Name:

Password:

or

First Test of Gyroscope and Accelerometer Code

by Octapoo

Thursday, October 15, 2020 at 13:34:00 UTC

Return to the Summary in Ecstatic Lyrics Blog

So I wrote this program to test my algorithms with the test data recorded by the data recorder I wrote about the other day. The first clip shows some normal flying with two turns in one direction and one turn in the other direction. The second clip shows a few loops.


It turns out it's a bit easier to, rather than track the plane's orientation in world space, to instead track the world's orientation from the plane's perspective. So the code keeps two vectors, one represents which way it thinks is east, and the other represents which way it thinks is up.

The three airplanes on the left show the plane from the sky looking down, from behind the plane, and from the right of the plane. The one in the top middle shows the plane from the east and thus is the only one that isn't going to flip the plane around when it turns up-side-down. The red line shows which way the plane thinks is east. The blue lines show which way the accelerometer data is pointing. Which direction the plane thinks is up is shown by the pitch and roll of the plane itself.

Below the video is a satellite map that's rendered from where the code thinks the plane is. I figured this was the easiest way to compare the calculated orientation to the video. As you can see, the pitch and roll are fairly accurate, the heading is kind of inaccurate, and location is kind of garbage. It turns out the GPS I have is kind of a piece of shit. The plane will make a turn, but the GPS will continue to give five location updates per second for several seconds that show it continuing on its previous path. It's like it barely knows where it is and for the most part it's just guessing.

I wonder how well using the accelerometer to determine location would work. Integrating the gyroscope works incredibly well, so maybe integrating the accelerometer to get speed, and integrating the speed to get location, might not be as bad as it sounds. However, the GPS units everyone else uses for this kind of thing are only $25, so I ordered one. That's quite cheap vs. the $75 I paid for this GPS module 15 years ago.

Anyway, I guess this part of the project basically works. The next step is to modify the flight simulator to output fake GPS and accelerometer data and accept control input from a test program so that I can work on some flight algorithms. I figure doing that before building electronics makes sense because if I can't figure out a flight algorithm then I'm wasting my time building electronics.

Comments


If you were logged in, there would be a comment submission form here.
Creating an account is easy. You literally just type in a name and a password.
I don't want your email address, so there won't be any links in any emails to click.

Return to the Summary in Ecstatic Lyrics Blog