COG or COM understanding? Flight dynamics

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

COG or COM understanding? Flight dynamics

Postby andygib » Fri Nov 23, 2012 10:50 am

Hi, not sure if you remember me but im the one who is lways trying to get my head around a flight simulator.

Well, i seemed to have come back around and having another play. Im using leadwerks which has built in NGD and im just trying to understand where the COD or COM (centroid) comes into it.

At the moement, i feel "close" but its definatly not right and still have issues.

The current way im doing this is by summing up the lift, drag and torque for each airfoil (left and right wing, tail wing and vertical stabaliser) and applying the net force and torque from them to the model.

Unfrotunatly im still getting unstable flight.

So some things im unsure of, where does the COG come in to this, at the moment im just "setting" the center of mass, but then using this no where in my calculations?

When i get the local position for each airfoil to us in my torque calculation, is the position relavtive to the COG?

Also, if im "setting" the COM (is that also COG?) how do i know the plane is in balance?

and lastly, the vertical Stabaliser (rudder), when calculing the force for this do you hve to calculate the force for left side and the force for right side?

Hope you can help.
Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby Julio Jerez » Mon Nov 26, 2012 12:54 pm

beleve that COG and COM are the same thing.
are you using drag coefficinet when you add your forces. bascially there is a rolling resistance coefficient og drag
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: COG or COM understanding? Flight dynamics

Postby andygib » Mon Nov 26, 2012 4:29 pm

Hi Julio, yes im calculated drag and applying that to the force.

What im a little confused about is the COM, do i just set the COM using the newton function?

Also, when I calculate the lift force for each airfoil, velocity is a function of the lift equation, can i just use the BODY verlocity? or does the velocity have to be the velocity at the airfoil point (the arifoil velocity), so taking into account rotation velocity?

If so, how do i calculate this?

Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby Julio Jerez » Tue Nov 27, 2012 12:29 am

can you show me the funtion that you are using to apply the forced to the vehicle?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 3:14 am

Yes sure I don't mind but which function is it you want to see? I'm using leadwerks with NGD built in. So I simply apply the final force to the body using using:

Body:setforce(finalforce)
Body:settorque(finaltorque)

Finl force is the sum of all airfoil forces and torque the is calculated from the resultant force applied at the airfoils local position to the body.

I have 6 airfoils left wing, right wing, tail wing, vertical stab right, vertical stab left & fuselage which each have there own coefiecient tables.

Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 6:02 am

I will upload a video showing my progress.

Although the plane flies, its still lacking characteristics that i know im doing wrong somwhere, for instance:

AOA the calculation for this i do not think is working, so therefore it is not getting the correct drag coeficient from the table, my AOA calc is:

Code: Select all
aoa_dir = TFormVector(Vec3(0,0,1),body,nil) //Facing direction in global space (front of matrix)
aoa_vel = Normalise(body:GetVelocity(1)) //Velocity of body in global spcace
aoavec = cross(aoa_vel,aoa_dir) //cross product of front & velocity vectors
aoar = math.asin(dot(aoa_dir,aoavec)) //resultant angle


The other thing i fail to get is "glide" characteristics, when i put power to 0, the nose drops but doesnt seem to gain speed from gravity.

Lastly, the velocity is use in my lift and drag equations comes from the BODY velocity and NOT the velocity at the airfoil point as I am unsure how to calculate this, can you tell me how?

Video is uploading now, ill add as soon as its finished.

Thanks you
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby Julio Jerez » Tue Nov 27, 2012 6:48 am

you have to have a loop where you calculate finalforce and finaltorque
that's the part that I like to see, because that part determine how the vehicle behaves.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 7:24 am

Here is the video: (not so good quality) (green line lift, red drag)
http://www.youtube.com/watch?v=VFgomg_O ... 8TjKOpfqww

The final forces are as follows: this is in a loop of all airfoils (1 to 6)

So for each airfoil: (this is not all the code, i have left out lift and drag equations)

Code: Select all
finalliftforce = calculatelift;
finaldragforce calculatedrag;

--combined force------------------------------------
finalForce = AddVec(finaldragforce,finalliftforce)

trans_finalforce = TFormVector(finalForce,nil,cubebody) //force in plane coords   

plane.airfoil.force[i] = finalForce

--combined Torque---------------------------------------------
pos = plane.airfoil.pos[i] //Airfoil local position from COM

finalTorque = cross(pos,trans_finalforce)

plane.airfoil.torque[i] = finalTorque


then for each airfoil again: (loop 1 to 6)
Code: Select all
airfoilforce += plane.airfoil.force[i]
airfoiltorque += plane.airfoil.torque[i]



Code: Select all
body:setforce(airfoilforce)
body:settorque(airfoiltorque)


Obviosuly this is not all the code, i am trying to give youthe bit you want.

Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby JoeJ » Tue Nov 27, 2012 8:34 am

Hi again

You can offset the "Center of Mass" from the "Center of Geometry" (means that?) using: NewtonBodySetCentreOfMass
Maybe you need to do that very early at setup, so inertia calculation can take it into account (?)
Note that the body matrix center now is not the center of mass anymore, to get the COM in world space you should need something like:
comLocal = NewtonBodyGetCentreOfMass()
comWS = bodyMatrix * comLocal

When you know the forces, their point of application and COM, you can use those formulas to apply the forces:
http://newtondynamics.com/wiki/index.php5?title=How_can_I_control_an_object_using_a_physics_engine%3F
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 9:12 am

Hi Joe, long time no see. :)

I am already using the SetBodyCenterOfMass in my planes config early on, and you can see from the video it seems to work fine. But i have set the COM to "somthing" that seems to fly ok, what i couldnt get my head around is this:

I fly RC planes and i check the COG (center of gravity) to see if they need any weight adding to the front or back to balance it out, so say i balance the plane at the COG which is normaly 1/3 back from the leading edge and it is tail heavy, i add some weight until it is balanced or a little nose heavy, at this point what has changed as the COG is still at the same point, but the overal mass center must have changed?

So how do i know if plane in my flight sim is "balanced" ok.

And the only other problem i have and ive read back trhought my old posts and still cant work it out and that is AOA.

The way i calculate it now works BUT the angle never goes negative, and it should.

Code: Select all
aoa_loc_dir = TFormVector(Vec3(0,0,1),cubebody,nil) --Facing direction (front of matrix)
aoa_loc_vel = Normalise(cubebody:GetVelocity(1)) -- Velocity of body
aoar = math.acos(dot(normalise(aoa_loc_vel),normalise(aoa_loc_dir)))
aoad = aoar*180/3.14159265


Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby JoeJ » Tue Nov 27, 2012 9:53 am

andygib wrote:So how do i know if plane in my flight sim is "balanced" ok.


To simulate the experiment from reality in newton you could place the plane on a high, small radius pillar.
If the pillar is aligned with the desired position of COG an it does not fall down quickly, it's right :)

How to find the angle sign example:

vec left(1,0,0); // your facing dir
vec up(0,1,0); // plane up dir
vec testA = vec (0.71, 0.71, 0); // pointing left up
vec testB = vec (0.71, -0.71, 0); // pointing left down
float angleA = math.acos(dot(left, testA ));
float angleB = math.acos(dot(left, testB ));
// both angles are the same :(
// to find the sign, we take the dot product with another, perpendicular axis to divide space in to halfs
float signA = dot(up, testA ); // positive
float signB = dot(up, testB ); // negative
if (sign < 0) angle = -angle;

So, in your case, the other axis should be the plane up axis, which is perpendicular to the facing axis.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 10:36 am

wow, thanks Joe, that is spot on and works a charm, the only thing i had to do was change up vec:

up(0,1,0); // plane up dir TO vec up(0,-1,0); // plane up dir

this game the AOA in the right direction. That is one thing that ive been struggerling with for while, so mcuh appriciated!

By implimenting that it has made the flight model a whole lot better, and actually uses the coeficent tables correctly now.

Still cant understand the "glide" though. For some reason when i turn "off" trust, the plane goes into a dive, but gains no speed, just goes down at a max speed which is quite slow.

Im using the standard gravity used in NGD, the lift being generated is perpendicular to veloctiy so not opposing gravity, so i cant understand whats not lettnig it generate speed in a dive.

Any ideas?

Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby Julio Jerez » Tue Nov 27, 2012 10:49 am

for the glide, and since you are controlling the body, did you ste the linar and angular drag to zero in the engine.
you need to set the integanl drag tozero and use the aerdinamic linar and rolling drag of an airfoil. The formula are very similar to lifg just the direction of accion is different the drag force.


BTW that video look quite nice, even with teh bad floag model you cna start to see that teh plane start behaving like a real air plane.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: COG or COM understanding? Flight dynamics

Postby andygib » Tue Nov 27, 2012 11:03 am

Hi Julio, thanks for reply. I assume you mean the drag implimented by leadwerks? If so then there is none, the only thing i am using is some small angular damping, but even if i set this to 0, i still get the same issue.

Could you elaborate a little on
you need to set the integanl drag tozero and use the aerdinamic linar and rolling drag of an airfoil. The formula are very similar to lifg just the direction of accion is different the drag force.


would be much appriciated.

Thank you for the comment about the video, it is much better now i have the correct AOA and coefficient tables working.

Thanks
Andy
andygib
 
Posts: 40
Joined: Fri Jan 13, 2012 7:47 am

Re: COG or COM understanding? Flight dynamics

Postby JoeJ » Tue Nov 27, 2012 12:09 pm

andygib wrote:By implimenting that it has made the flight model a whole lot better, and actually uses the coeficent tables correctly now.


Good, but there's one more problem case:
If the velocity gets aligned with the planes side axis, AOA may jump between -/+ 90 degrees,
resulting in large rapid changes of the calculated forces.
To damp that away you should do something like:

float damp = 1.0 - fabs(dot(planeSide, velocity));
force *= damp;

That's not a hacky bugfix, it should improve realism too.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest