Want to test code with the simulator X-Plane?

Here's an example of how to get data from the simulator: http://gist.github.com/228998

It has everything you need to treat it as a virtual IMU. This was instrumental in getting my extended Kalman filter running (to be open sourced soonish) and I hope you find it useful too!

(I'll do an updated version that shows you how to control the plane in X-Plane from your code.)

Views: 308

Comment by Stephen Shorrock on November 7, 2009 at 9:07pm
Nice work, what data in/out settings have you got in xplane?
Comment by Tim Trueman on November 7, 2009 at 9:20pm
In the example code I'm grabbing the gyros, accelerometers, indicated airspeed, altitude, lat/long and heading. You can read a lot more data if you want (I'm taking probably 1% of the data available for access from X-Plane). Download the demo and go to the input/output menu to see what's available.

I would recommend reading the comments in the code. I actually spent some time explaining what's going on…
Comment by Stephen Shorrock on November 7, 2009 at 10:39pm
ah got it, different versions of xplane.
Comment by Faisal Shah on November 8, 2009 at 1:30am
I was able to run a closed loop simulation with FlightGear as well. It's super easy ... in fact, all that you need is already done and explained in my blog posts. The only thing left to do is to flesh out the C code with your IMU/autopilot code and test away!

http://www.diydrones.com/profiles/blogs/closed-loop-autopilot
http://www.diydrones.com/profiles/blogs/closed-loop-autopilot-1

X-plane looks interesting, I'm gonna check it out!

Developer
Comment by jasonshort on November 8, 2009 at 10:27pm
I just bought Xplane last week to do this. Thank goodness I can use your code! I can't believe what a good deal this program is.
Comment by Andy Geppert on November 8, 2009 at 10:40pm
Faisal, I'll be curious to hear a comparison between FlightGear and X-Plane with respect to ease of adding it into the loop. Thanks for your links too!

Any good sources you guys are using for smaller (R/C) planes in X-Plane? I've been a big fan of X-Plane for some time - it is a great simulator, especially if you have a techy bent...
Comment by JC on November 13, 2009 at 7:48am
Tim,
What variables are you using for accelerations from X Plane. From the input/output menu I see the angular rates but not the accels.
Comment by Tim Trueman on November 13, 2009 at 10:20am
Gload is what you want to look for…

self.az = unpack_from('f', data, 9+16+36)[0] # normal
self.ax = unpack_from('f', data, 9+20+36)[0] # axial
self.ay = unpack_from('f', data, 9+24+36)[0] # side
Comment by Jason Slay on August 21, 2011 at 3:45pm

Any chance we will see the updated post with the control commands? Thanks!

Comment by Tim Trueman on August 21, 2011 at 8:30pm
@Jason Slay

I am working on an updated post with code. It includes a bunch of updates but due to work limiting my time it probably won't be ready until January.

This might get you started if you're a confident programmer: https://gist.github.com/1161599

Comment

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

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service