Advertisement

RC Flight Simulator, airplane physics

Started by June 10, 2013 04:15 PM
5 comments, last by MrRowl 11 years, 8 months ago

Hello,

I am currently trying to implement a RC Flight simulator in c++ for a course at my current university.

The problem is that as a beginner when it comes to physics in games i dont know how to implement the physics of the airplanes. I think i understand the basics of flight well enought but i need some help with the implementation, i dont want to reinvent the wheel if i dont have to.

I am currently trying to find a paper or book or something that gives me a nice overview of what is needed to create airplane physics so any suggestion is appreciated.

The goal is not to create a perfect simulator that simulates the physics perfectly based on the individual airplane models shape. But i dont want it to be to much like an arcade game either, somewhere inbetween.

Im not planning on calculating wing area, weight or other airplane specific parameters but rather have them defined. So i basically aim at creating one flight model that all airplane share for simplicity.

So does anyone have any suggestion of where i should start?

Suggestions on papers, books or anything else is welcome.

Thanks in advance,

zevvan

I would start with pen and paper, and see how much of "the basics of flight" that you do understand. A book I highly recommend is Physics for Game developers. It is by far my favorite code oriented book on the subject, and goes through the physics of not only flight sims, but particles, rigid bodies, collision restitution, ships(buoyancy), hovercrafts, cloth, and more. The code is also available from the publishers site for free IIRC.

Advertisement

I would start with pen and paper, and see how much of "the basics of flight" that you do understand. A book I highly recommend is Physics for Game developers. It is by far my favorite code oriented book on the subject, and goes through the physics of not only flight sims, but particles, rigid bodies, collision restitution, ships(buoyancy), hovercrafts, cloth, and more. The code is also available from the publishers site for free IIRC.

I wouldn't touch that code even if somebody paid me to! The book is terrible and the code is even worse. The rigid body example blows up if you let run a fraction longer. This is based on my reading the book/examples quite a few years ago, but I don't believe they've been updated since, which is pretty shameful.

Anyway, back to the question:

There are two basic approaches:

1. Represent the aircraft as a point (rigid body). Calculate the responses - either using an offline tool or by guessing - i.e. the rate of change of linear and angular velocity as a result of the airflow (relative to the plane, obviously) and its spatial derivatives at that point. You'll also need to handle the special cases explicitly - stalling of the wing (both sides), one wing only (if you want to simulate spins/tip-stalls), wing + tail etc etc...

2. Represent the aircraft as a collection of independent wing sections. You need to write a function that lets you calculate the lift and drag (and possibly pitching moments) for each wing section - and apply those forces/torques to the rigid body. The force calculations can be relatively simple, and it's not hard to make up some lift/drag curves that work quite well.

You can get a long way with both approaches. The first, if combined with a really good tool for the offline calculations, can give you very accurate results for normal flight. However - you can end up with a lot of parameters that don't really mean much if you want to tweak things. If the tool is good, then it will automatically include things like the effects of the wing downwash on the tail etc... One open-source simulator that uses this method is CRRCSim.

The second method is probably computationally more expensive, but it's still not a big deal. In its basic implementation it won't incorporate the effects of downwash etc so may not be quite as realistic as a perfectly set up version of the first method. However - it's very easy to tweak the parameters, you can add in the secondary effects if you figure them out, and many things just emerge - e.g. the ability to stall just part of a wing. One open-source simulator that uses this method is my own Slope Soaring Simulator.

At the time I wrote SSS there wasn't much info around, and I wasn't aware of anybody else using the method. However, I think it's reasonably common now.

Here's a plug for the latest version of my simulator (a rewrite) called

">PicaSim - running on PC, iOS and Android. It's not open source, but if you download the free Windows version, it contains all the data files, including the description of the planes in xml format, so it's quite easy to figure out how the thing works.

- Danny

Hi,

Thanks for the answers they were both very helpful. I took a look at the capter in book Physics for Game developers describing a simple flight simulator and it gave me a clear description of the theory but i am still not sure how to make it work.

I am currently planning on using the approach mentioned both in the book and in the post by MrRowl.

2. Represent the aircraft as a collection of independent wing sections. You need to write a function that lets you calculate the lift and drag (and possibly pitching moments) for each wing section - and apply those forces/torques to the rigid body. The force calculations can be relatively simple, and it's not hard to make up some lift/drag curves that work quite well.

I have some problems understanding how to use the drag and lift for each wing section to "update" the rigid body.

I figure i will calculate the forces for each of the two ailerons, the rudder and one force for the elevator.

But i am not sure how to apply these forces to the body correctly. So if someone know of a more detailed source or is willing to give a quick explanation of how to combine these forces it would be a big help.

I could add that the main aim of this project is the graphics so i would prefere finding a nice simple solution to the physics that i can manage to understand and implement fairly easy, giving me more time to focus on the graphics.

Thanks in advance.

zevvan

Physics For Game Developers, already suggested, has all the information you need to get a simple simulator up and running. It might not be perfect, and won't turn you into an aeronautical engineer but it's not meant to do that.

You will find explanations and tutorials from rigid body basics, to airplane basics.

Get it, read it and code.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

I would start with pen and paper, and see how much of "the basics of flight" that you do understand. A book I highly recommend is Physics for Game developers. It is by far my favorite code oriented book on the subject, and goes through the physics of not only flight sims, but particles, rigid bodies, collision restitution, ships(buoyancy), hovercrafts, cloth, and more. The code is also available from the publishers site for free IIRC.

I wouldn't touch that code even if somebody paid me to! The book is terrible and the code is even worse. The rigid body example blows up if you let run a fraction longer. This is based on my reading the book/examples quite a few years ago, but I don't believe they've been updated since, which is pretty shameful.

hmm, I've not found that issue at all. Perhaps my c++ is too terrible to notice how bad the book's code is? Could you elaborate?

Advertisement

hmm, I've not found that issue at all. Perhaps my c++ is too terrible to notice how bad the book's code is? Could you elaborate?

My review on Amazon here -

http://www.amazon.co.uk/review/R176KKGONKXMF5/ref=cm_cr_pr_perm?ie=UTF8&ASIN=0596000065&linkCode=&nodeID=&tag=

Maybe I'm picky... I don't know (well... actually I do know - I'm extremely picky about getting stuff right, which is pretty essential if you're going to do any serious programming, especially physics coding!). But this bug sits at or near to the bottom of any list on three counts: 1. clarity/consistency of the text, 2. functionality of the samples and 3. code quality of the samples. I haven't kept up with what printed books there are, but I find it hard to believe there's nothing better by now.

Actually - I see there's a new version: http://www.amazon.co.uk/Physics-Game-Developers-realistic-Leverage/dp/1449392512/ref=sr_1_1?ie=UTF8&qid=1371244625&sr=8-1&keywords=physics+for+game+developers It does appear that at least some aspects have been improved, though I can't see much on there. Still doesn't stop me bearing a grudge about having wasted my money on the first version, though :)

This topic is closed to new replies.

Advertisement