View Full Version : Question API for FMS?
AnthonyRC
Oct 07, 2005, 08:55 AM
Does anyone know of a way to interface to FMS (or something similar) in order to retrieve the plane's position, height, etc. and send in control movements?
I'd like to test some Autopilot algorithms in the presence of wind, turbulence, etc. and this would seem to be a safe way to do it.
clolson
Oct 07, 2005, 10:13 AM
I don't know about FMS, but being one of the primary author's of FlightGear I have to suggest you take a look here: http://www.flightgear.org
FlightGear is targeted more towards full scale aviation, but there's no reason why you can build a small R/C model ... I believe people have done it before.
The nice thing about FlightGear is that it is fully open-source, and it has endless interfacing options depending on exactly what you want to do.
You can disable FG's internal flight dynamics engine, and blast position/orientation/etc. at it via UDP packets from an external source. This allows you to slave FG to live IMU/INS/GPS output from your UAV giving you a live synthetic view of your uav, or you can replay your flights later if you capture the data.
You can go the other way too. If you activate FG's internal flight dyanmics engine (for some model you have created) you can have FlightGear send position/orientation/etc. data to your external program (autopilot), and that program can in turn send back control inputs. This sounds more like what you want to do.
You can use the built in networking code to slave multiple copies of FG together. This allows you to setup multple visual channels for a wrap around view if you want to get really fancy.
There is also a more "low bandwidth" interface that allows you to examine and change just about any internal variable in the simulator. I've used this interface to develop a set of remote scripts that automatically fly all the FAA level 3 FTD certification test, log the approriate data, and spit it out in graph or number (depending on the test).
FlightGear has reasonably accurate scenery for the entire world based on SRTM terrain data and VMAP0 roads, rivers, lakes, etc. So you can fire it up in your favorite spot in the world and see a reasonable representation of what is really there.
We are working on building a "photo-realistic" model of our flying area. Once that is done we are looking forward to comparing the live video with the live "photorealistic" synthetic view.
There's going to be a bit of a learning curve with FlightGear, but we have support mailing lists, forums, irc, etc. and I think once you get going with it, you'll really like it's power, flexibility, and open-sourc-y-ness.
Regards,
Curt.
LukeZ
Oct 07, 2005, 11:43 AM
FlightGear really sounds like a great program; I'm going to have to play with it at some point. Another I've seen on the web is X-Plane (http://www.x-plane.com/about.html). I can't say I know very much about it but I believe it may also be possible to do what you suggest with it as well. Again I can't be sure but it's worth a look. I'd be interested in hearing what others might have to say about it who've had some experience with it.
Luke
clolson
Oct 07, 2005, 12:49 PM
I'm so involved in FlightGear that I'm not really able to be objective, so bear that in mind.
I will say that X-Plane is a nice commercial program. I've downloaded a recent demo and it has some nice graphics and animations. It also has some interfacing options, and you can probably do what you want with it too. It's approach to flight modeling is that you punch in the mass, geometry, and airfoil of your aircraft, and then it has a technique to predict the flight behavior of your aircraft from that information alone. The downside though is if it doesn't get the performance of your aircraft just right, you then have to start tweaking your mass and geometry away from reality in order to get performance closer to reality. I think that procedure may involve sacrificing chickens, but I'm not sure. The other thing I've heard is that their flight dynamics don't scale down real well to small UAV's. That's just what I've heard, I haven't tried it myself. But I don't want to sound negative, I know that X-Plane has a ton of nice features to offer and I know that Lockheed Martin has used it for some of their uav development work.
But FlightGear is free and open-source so if you anticipate you might need to interface in some non-standard way, or do something new that the developers haven't anticipated, or would like to integrate some of you own code, I think FlightGear is a good, flexible, solid choice.
Regards,
Curt.
Unterhausen
Oct 07, 2005, 01:14 PM
I'm so involved in FlightGear that I'm not really able to be objective, so bear that in mind.
...snip...
But FlightGear is free and open-source so if you anticipate you might need to interface in some non-standard way, or do something new that the developers haven't anticipated, or would like to integrate some of you own code, I think FlightGear is a good, flexible, solid choice.
Regards,
Curt.
I just downloaded a uav flight control simulink blockset that works with flightgear from http://www.u-dynamics.com/aerosim/
Haven't had a chance to set it up.
Our research group uses flightgear as a human interface for our rotorcraft research. Works great.
Unfortunately, on my computer at home, it runs so slowly that I can't use it. I need to get a faster computer.
Eric
AnthonyRC
Oct 07, 2005, 02:24 PM
Many thanks guys, this is exactly what I've been looking for. Just downloading flightgear and x-plane and I'll put em through their paces.
At a first glance they look pretty similar, although I see that x-plane has some radio controlled models in their aircraft library. Haven't found any yet for flightgear, but still looking.
clolson
Oct 07, 2005, 02:37 PM
For what it's worth, the latest simulink aerospace blockset has an interface built in to work with FlightGear-0.9.8 (most recent version). The u-dynamics stuff was developed a while ago and requires an earlier version. That probably doesn't matter for most people, unless you need the latest greatest.
Curt.
LukeZ
Oct 07, 2005, 03:01 PM
Curt,
Don't worry about being biased! I'm really interested in finding out the differences between these two. I really know nothing about either.
What I'd like to be able to do is mock up my UAV in one of these programs, have the flight controls into the sim come from my autopilot circuit, and the sensor input into my autopilot be the output from the sim, and see how it goes. Given that I'm trying to build a long distance UAV, this would allow me to simulate an entire 2,500 mile voyage in a virtual world, monitoring how my autopilot works, over the actual terrain that it would have to follow in real life. If real-time weather could be thrown in that would be even more cool.
It sounds like either program could probably accomplish this - at least what you're saying is that FlightGear could (don't know about the real-time weather or not, but since it's open source I could program that myself).
What I'm curious about is which one would best model the actual dynamics of a small craft such a 10 foot wingspan UAV, instead of a full-sized civilian plane. You alluded to the method X-Plane uses, (not that I necessarily understood it all :o):
Its approach to flight modeling is that you punch in the mass, geometry, and airfoil of your aircraft, and then it has a technique to predict the flight behavior of your aircraft from that information alone. The downside though is if it doesn't get the performance of your aircraft just right, you then have to start tweaking your mass and geometry away from reality in order to get performance closer to reality. I think that procedure may involve sacrificing chickens, but I'm not sure. The other thing I've heard is that their flight dynamics don't scale down real well to small UAV's.
Ok, so how does FlightGear's set up differ from the above? I was browsing your site and it looks like there are actually two or three different areodynamic engines that could be used. Is there one or the other that would be more realistic for small craft?
Also, can you describe it in layman's English? :D
Luke
clolson
Oct 07, 2005, 04:18 PM
Hi Luke,
FlightGear has a pre-defined flight controls network packet/structure that it can accept instead of keyboard/mouse/joystick input. FlightGear has a similar standardized packet structure for all the flight dynamics variables.
You can configure flightgear to send the flight dynamics variables in this standard structure to your "autopilot" application every frame. You autopilot app can take this "sensor" data (notice it is perfect data, sensor modeling is an additional subject) then crunch your autopilot algorithms, generate control inputs, and send those back to FlightGear. If you thought it through and built the proper hardware interfaces, you could probably involve your actual flight computer in the loop. FlightGear can generate fake gps strings for instance and send them out the serial port to be read by some piece of hardware/software that expects to be connected to a gps.
FlightGear does have a live real weather implimentation. It pulls the current data for the closest weather station periodically.
I'm not a flight dynamics guy so I can't speak authoritatively on that subject, but I'll tell you what I know (which won't take long except that I'm typing it in.)
FlightGear has a couple different flight dynamics engines you can choose from.
If you are an aerospace engineer, you probably want to build a model out of aerocoefficients and stability derivatives and all of that mind blowing stuff. In that case you would pick JSBsim which allows you to define all the parameters and data you could ever want in a convenient well structured "human readable" xml file.
If you don't want to beat yourself over the head with that hammer, you might take a look at YAsim and see if that will work for you. YAsim is really a nifty chunk of code that works amazingly well for what it is. You start out by inputing the mass and geometry of your aircraft in a config file. You specify things like your wing dimensions and placement, size and location of ailerons, etc. You specify your tail surfaces, your engine location and power (and weight.) You specify gear location, etc. etc. There are facilities for distributing the available mass throughout the aircraft, locating the fuel tanks, etc. so that the CG is correct and changes as fuel burns. This is all stuff that you can figure out with a ruler and a scale if you have your aircraft in front of you.
Finally, you need flight performance data ... in this case hopefully you can do some test flights to get actual data (or close approximations to actual data.) 1. you need a cruise configuration ... altitude, speed, throttle position. 2. you need an approach configuration which basically is an approach speed and angle of attack for your aircraft.
Given all this information, YAsim figures out lift and drag coefficients so that your model nails your performance specifications exactly. Then armed with a bunch of physics math, it does a reasonable interpolation of the flight behavior every where else. You might be a bit sceptical, but it really does a nice job and you can get up and flying without needing to be an aerospace engineer. And unlike X-Plane you tell yasim what the perfomance is and it makes it happen. X-Plane you define your airplane as best as possible and it decides how it will perform.
All of these different routes to modeling the behavior of an airplane are appropriate for different situations, so none of them is inherently better or worse ... but they are different and have their own individual strengths and weaknesses.
Curt.
Unterhausen
Oct 07, 2005, 04:27 PM
Curt
Thanks for all the work that you've done in this thread. I got my degree in Aeronautical engineering in '85, and I barely remember any flight control. I've been been kind of lost as to where to start, and you've been a big help.
Eric
AnthonyRC
Oct 07, 2005, 04:47 PM
Hum... ok, installed both FlightGear and X-Plane. Both look quite interesting. I started with X-Plane and tried to get the UDP stuff working... but failed, seems overly complex for what I'm looking for.
So now onto FlightGear, seems to run ok, much simpler to drive than X-Plane, but I haven't been able to find much documentation, or examples, for the UDP connection.
Any useful pointers on this Luke?
LukeZ
Oct 07, 2005, 05:11 PM
Nope, not from me - I haven't even installed it yet! :o
I'm going to download it tonight and try to play with it this weekend...
Luke
AnthonyRC
Oct 07, 2005, 05:36 PM
Ooops, sorry, I meant Curt :-)
clolson
Oct 07, 2005, 07:05 PM
So now onto FlightGear, seems to run ok, much simpler to drive than X-Plane, but I haven't been able to find much documentation, or examples, for the UDP connection.
Any useful pointers on this Luke^H^H^H^HCurt?
What's to document? :-)
I'd start by looking through the docs-mini/README.IO file. It's brief, but gives you an overview of the basics of configuring FlightGear to accept or send "standard" data packets. (And I say 'standard' in the sense that if you don't like any of the existing standards just make up your own.) :-)
From there, take a look at the source code in src/Network/net_fdm.hxx
That file defines a "public-domain" structure (so it can be utilized in any code, open-source or proprietary.)
Essentially what you want to do is write some code that fills in this structure with the appropriate data and send it over to FlightGear, or in your case you will probably be receiving this structure, and extracting the desired fields out of it for use as your "sensor" input.
If you fetch the cvs (development) version of the code (details on our web site) there are a couple examples of reading data from a gps or the MIDG-II IMU, packaging it up in FG friendly format and shipping it off to FlightGear. This allows replaying saved data, or playing live data.
There's definitely an element of do-it-yourself in FG, but it's all there to dig into and examine.
Best regards,
Curt.
LukeZ
Oct 07, 2005, 10:02 PM
If you are an aerospace engineer, you probably want to build a model out of aerocoefficients and stability derivatives and all of that mind blowing stuff. In that case you would pick JSBsim which allows you to define all the parameters and data you could ever want in a convenient well structured "human readable" xml file.
Curt, as it turns out I do have an aerospace engineer helping me out on this project. ;) What is the more difficult aspect of this approach? Does it simply involve more empirical testing of the structure to accumulate real-world performance data?
Luke
clolson
Oct 07, 2005, 11:19 PM
Curt, as it turns out I do have an aerospace engineer helping me out on this project. ;) What is the more difficult aspect of this approach? Does it simply involve more empirical testing of the structure to accumulate real-world performance data?
Luke
Well, my degree is in computer science[1] so you may want to ask your buddy rather than me. :-) But, the more technical "JSBsim" approach is not insurmountable. We have two tools in particular (aeromatic and DATCOM+) that will generate a reasonable config file for you. Then you can tweak and tune numbers from there ... hopefully your friend can have some understanding of what the numbers mean and how they impact flight performance ... just browsing a config file, you need to fiddle with things like lift coefficient, drag coefficient and the different parameters that might affect those ... alpha, beta, flaps, elevator deflection, pitch rate, gear position, roll moments, pitch moments, and then you end up with pitch moment due to alpha, pitch moment due to elevator, pitch moment due to pitch rate, pitch moment due to alpha rate, etc. etc. etc.! Most of those effects make some sort of sense to me, but quantifying them and adjusting them so that everything comes out right for your airplane is really tricky ... let's say the period of your phugoid is 20% off, now what are you going to do? Or maybe if you put your airplane into a steep 60 degree bank, the real thing will slowly recover to maybe 45 degrees and stabalizes there in a spiral, but maybe the computer model wants to diverge into an ever deepening spiral ... what do you change to fix that? It gets really fun. Oh, so then you fix your model so the change in elevator deflection needed to hold level flight at 80 kts as flaps are deployed is just like the real airplane, but now your stall speed goes out of whack. You can end up chasing your tail in circles trying to get every aspect of your model right at simultaneously.
I know just enough about it to know when I need to run away with my tail between my legs!
Curt.
[1] These days I think a Csci degree will get you entry level wage at Wendy's and they might even let you run the cash register if you have your master's degree.
Oh, just a dumb PS here. My 4.5 year old daughter loves spongebob squarepants, and she noticed that he has a job is flipping burgers at the Krusty Krab. So she has announced on several occasions that she would like to be a burger flipper when she grows up. :-)
moon-dawg
Oct 18, 2005, 09:31 AM
Unterhausen,
That AeroSim Blockset for Matlab/Simulink looks great!
I wonder if those Pesky Al-Qaeda UAV designers used it to model their Wing Dragon UAV. I am sure it would have shown that a 1 Kilo payload was impossible. HaHa...
Did you read this?
http://news.bbc.co.uk/1/hi/programmes/from_our_own_correspondent/4278554.stm
moon-dawg
Oct 31, 2005, 12:13 PM
Unterhausen/Clolson,
Over the weekend I downloaded The AeroSim Blockset from www.u-dynamics.com and the latest version of Flight Gear from www.flightgear.org .
I installed both programs and then started going through the AeroSim Users Guide to learn how to use The AeroSim Blockset. When I got to page 17 of the AeroSim UG (the part that shows how to interface to FlightGear) I entered the command and it did not work!
I looked and my directory structure was not quite as shown in the UG. The command I had to use was:
bin\WinXP\fgfs --native-fdm=socket,in,30,,5500,udp --fdm=external
When I entered this I got another error ... something about not being able to find 0.9.8 in \flightgear.
Does AeroSim work with ver 0.9.8a? My version is 0.9.8a... According to the UG (pg 1) AeroSim only supports 0.9.4.
Did you run into the same problem when you installed this bockset on your computer?
clolson
Oct 31, 2005, 12:15 PM
As I understand it, the aerosim stuff only works with the older version of FlightGear.
Matlab's newest aerospace blockset has built in support for FlightGear v0.9.8
Regards,
Curt.
treehog
Dec 27, 2005, 04:14 PM
clolson thanks for your inputs to flightgear
I have a mac g4 any issues would it be best to run on linux
or stay with
mac osx 10.4
In my projectmodel uav project
I want to simulate the entire project
before comiting real equipment every aspect including the wiring up of the component into the craft
figure it will be some sort of gumstix
Inital project 3m glider(I have one to spare)
return to base from lost rx signal down to landing of sorts in case of broken rc reciever
I willl start a thread for the project at this new location
( http://www.rcgroups.com/forums/showthread.php?t=457281#post4792505)
responses to the thread new location probably best
Ralf
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.