Sign in to follow this  

Modeling flight with ODE

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a simplistic flight simulator built off of ODE. I've got straightline flight down; lift, thrust, drag, and gravity all work beautifully. The problem comes when the user pitches or yaws - obviously, ODE keeps the same velocity vector regardless of a body's rotation (although it happily thrusts in the new direction). I'm a little stumped on how to fix this.

I know what I want to do conceptually - I want to keep the plane's momentum along the same relative axis, rather than the world axis. I'm just not clear how to do this. At the moment I'm trying to counter the momentum in the old direction and reapply it along the new, but I'm not clear how to figure out the rotations involved. I'm also not real strong on matrix math - I'm happy to learn, but at this point, I don't know what to research. Or is there another easy method I'm missing?

Thanks for any help!

Share this post


Link to post
Share on other sites
Planes don't just turn their velocity. A plane's heading changes because its rudder causes a lateral force on the tail which leads to yawing torque. As the heading changes, the thrust is directed in a new direction, while drag reduces the velocity in the old direction.

In short: Forwards thrust + linear drag + lateral thrust on the tail = plane turning.

Share this post


Link to post
Share on other sites
I have included an airplane to the "IrrOdeCar" demo of my Irrlicht-ODE wrapper (check out http://bulletbyte.de/products.php?sub=irr&show=irrode ). It's far from being realistic, but it works. I just use the orientation of the plane and add some forces before each simulation step.

The actual flight stuff is done with 2 classes:

- CIrrOdeAeroDrag: this class adds the forces necessary to have the plane look like a plane
- CIrrOdeTorqueMotor: this one is used for the rudder controls

You can take a look at it and try the demo. If you have any further questions feel free to ask ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Planes don't just turn their velocity. A plane's heading changes because its rudder causes a lateral force on the tail which leads to yawing torque. As the heading changes, the thrust is directed in a new direction, while drag reduces the velocity in the old direction.

In short: Forwards thrust + linear drag + lateral thrust on the tail = plane turning.


Wouldn't that mean that if the engine power was cut before the yaw, the rudder would turn the plane, but it would still continue on the old heading (until drag stopped it)? Or does "thrust" here mean the plane's forward momentum, rather than the force being exerted by the propeller?

Brainsaw - I had a look at your program. From the way it behaves, it seems like a pretty good model for me to use; but I'm still trying to deconstruct it. It looks to me like in CIrrOdeAeroDrag, you're getting the plane's local forward velocity vector, and setting the lift to be a factor of that, within a few constraints, is that right? And then you apply a force along a combined lift and thrust vector? And then in CIrrOdeTorqueMotor you just add torque forces to each axis based on the throttle setting and the input settings?

Also, are you using a model like what Sneftel described? I didn't notice anything dealing with drag, but the program seems to behave as if it processes it if I lower the throttle.

Share this post


Link to post
Share on other sites
Quote:
Original post by sts5577
Wouldn't that mean that if the engine power was cut before the yaw, the rudder would turn the plane, but it would still continue on the old heading (until drag stopped it)?
Yes. Now, that model is somewhat simplified: as the plane turned diagonal relative to its velocity, its body would act as an airfoil, imparting some velocity in the new direction. Not much, but some.

The other way in which that model is simplified is the roll component of turns. When a real plane turns, it uses its ailerons to roll in the direction of the turn; this means that the airfoil (the real airfoil -- the wings) which normally imparts upwards force to counteract gravity, then begins to impart centripetal force (when combined with the elevators pitching the plane's nose up), causing the turn. (Basically, think of a plane performing a vertical loop. Now think of that sideways.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Now, that model is somewhat simplified: as the plane turned diagonal relative to its velocity, its body would act as an airfoil, imparting some velocity in the new direction. Not much, but some.


As long as the new velocity is less than 10% or so of the original velocity, I'm not too worried about it. All this talk of drag though did finally lead me to my problem - I've always been adding drag as a force opposed to the thrust, rather than the velocity! I am adding lift as a force on the body's local positive y-axis too; so I think I've got the centripetal force aspect already covered.

Anyway, now I just need to calculate a usable drag force - it's based on the square of the velocity, right? So I can take the body's velocity vector, and multiply each element by -1*(vel**2)*(some force constant) and add that force to the body to generate a simplistic drag model?

Share this post


Link to post
Share on other sites
Quote:
Original post by sts5577
Anyway, now I just need to calculate a usable drag force - it's based on the square of the velocity, right?
Directly proportional to the velocity is the most common drag model. And remember, objects have different amounts of drag in different directions.

Share this post


Link to post
Share on other sites
Quote:
Original post by sts5577
Quote:
Original post by Sneftel
Planes don't just turn their velocity. A plane's heading changes because its rudder causes a lateral force on the tail which leads to yawing torque. As the heading changes, the thrust is directed in a new direction, while drag reduces the velocity in the old direction.

In short: Forwards thrust + linear drag + lateral thrust on the tail = plane turning.


Wouldn't that mean that if the engine power was cut before the yaw, the rudder would turn the plane, but it would still continue on the old heading (until drag stopped it)? Or does "thrust" here mean the plane's forward momentum, rather than the force being exerted by the propeller?

Brainsaw - I had a look at your program. From the way it behaves, it seems like a pretty good model for me to use; but I'm still trying to deconstruct it. It looks to me like in CIrrOdeAeroDrag, you're getting the plane's local forward velocity vector, and setting the lift to be a factor of that, within a few constraints, is that right? And then you apply a force along a combined lift and thrust vector? And then in CIrrOdeTorqueMotor you just add torque forces to each axis based on the throttle setting and the input settings?

Also, are you using a model like what Sneftel described? I didn't notice anything dealing with drag, but the program seems to behave as if it processes it if I lower the throttle.


IIRC (am currently at work and don't have the source code here) it works like this:

The lift is calculated from the foreward velocity only. You'll notice that the plane will almost fall down like a stone if you do a really steap turn. If there's no foreward movement there will be no lift.

The torque motor does also take the foreward velocity into account, the throttle settings have no influence (OK ... they have. The foreward velocity gets higher if you increase the throttle)

The model takes the three directions as seperate values (foreward, sideward and upward damp). You can set seperate values for all of these. I found this is the best way to do it (without being a physics expert).

The torque motor can also be changes by parameter to not take the foreward velocity into account. I need this for the helicopter.

I hope I could help a little, but when writing this answer I realized that I already forgot a lot of this stuff again ;)

Share this post


Link to post
Share on other sites

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this