 # External Dll data questions

• Hi guys,

I'm adding Aerofly FS2 compatiblilty into SimShaker - Wings application to provide event-driven force feedback via Gametrix JetSeat or bass-shakers.

I wonder what are measurement units for

Aircraft.IndicatedAirspeed

Aircraft.VerticalSpeed

Aircraft.GroundSpeed

?

Haven't found that in external dll sample comments.

Are those params reported in m/s or those depend on aircraft type/country?

• Hi guys,

could somebody tell me how to calculate G force from the data exposed by Aerofly to external DLL?

I'm in doubts.

• Official Post

if there is an acceleration output already present then just take that and divide by 9.81 [m / s^2] and you get "g"

If not you can still add a sender manually in the tmd files and make it send the accelerometer output.

Otherwise, if you have access to the body's speed and rotation speed then you can use normal code to calculate the acceleration...

I'm not sure what you have available with the dll Regards,

Jan

• if there is an acceleration output already present then just take that and divide by 9.81 [m / s^2] and you get "g"

Yes, I was intended to do that.

But I don't quiet understand figured I'm getting with external dll sample from Aerofly.

Please have a look at my screenshot. It's about a level flight and G should be about 1, but I can't get it from the Accelerations if I divide by 9.81.

• Official Post

AH, well there you have it - acceleration x, y and z even!

z is upwards in the aircraft reference frame and Aircraft.Acceleration (the second one) is the relative acceleration of the body, 0.0 on all axis means the aircraft will fly a straight line. The -0.104 in the z component is what you are after I think. That is 1.0 minus 0.0106 gs down -> total of 0.9894 gs

Code
``double g_factor = 1.0 + Aircraft.Acceleration.z / 9.81;``

you could also subtract the Aircraft.Gravity from the Aircraft.Acceleration and then take only the z component and divide that by 9.81 to get a better result.

Code
``double g_factor = ( Aircraft.Acceleration - Aircraft.Gravity ).z / 9.81;``
• Official Post

Hi admin But that would be world up, he needs the up vector of the body, how would he get that from the quaternion Aircraft.Orientation?

Not that much of a difference for straight and level flight and especially not for the A320 - you could correct using some trigonometry and the bank and pitch values that are also provided

Regards,

Jan

• Official Post

Jan: I tried to point out that the z-axis is not the 'up' vector. We have seen cases, where people mix this up.

Aircraft.Acceleration is in the aircraft reference system, whereas Aircraft.Orientation is the orientation quaternion of the aircraft in world coordinates.

If you need the world up vector, simple normalize Aircraft.Position, as a good approximation.

Aircraft.Orientation is also in world coordinates. On can get the world orientation matrix like this

Code
``````tmmatrix3 QuaternionToMatrix( const tmquaternion &q )
{
return tmmatrix( 1 - 2 * ( q.y*q.y + q.z*q.z ),     2 * ( q.x*q.y - q.r*q.z ),     2 * ( q.x*q.z + q.r*q.y ),
2 * ( q.x*q.y + q.r*q.z ), 1 - 2 * ( q.x*q.x + q.z*q.z ),     2 * ( q.y*q.z - q.r*q.x ),
2 * ( q.x*q.z - q.r*q.y ),     2 * ( q.y*q.z + q.r*q.x ), 1 - 2 * ( q.x*q.x + q.y*q.y ) );
}``````

Where the first component of Aircraft.Orientation corresponds to q.r, the second component corresponds to q.x and so on.

• Official Post

Jan: I tried to point out that the z-axis is not the 'up' vector. We have seen cases, where people mix this up.

Yeah that would be me It's important to differentiate between local aircraft up, local world up and world up (in which speed, orientation, etc. are defined). Is world up just the North Pole? And would x point to 0° longitude and y to 90° longitude?

Well if Aircraft.Acceleration is in the aircraft reference system than that is up in the aircraft, is that correct?

That is not the local world up which you would need to define if the aircraft starts ascending or descending, but if I want the g-force in the seat isn't that just the z-component of that local aircraft acceleration vector? And that would be the second Aircraft.Acceleration in the list (screenshot above)?

Thank you for the code! How would I calculate the aircraft's speed for example in the aircraft reference system? (x = forwards, y = to the left, z = up from my point of view as the pilot) Can I just do v_rel = QuaternionToMatrix( Aircraft.Orientation ) * Aircraft.Velocity? Isn't that what the second Aircraft.Velocity already does for us? I assume the flags are where I can distinguish between the first and second message...

I think I should play around with this more, I'm pretty sure there are a lot of awesome things that I could do with the external dll. If only the day had more hours (Andre, are you still with us?)

Regards,

Jan

• Well wait a minute, that just depends. G are usually for normal (to the horizontal median plane of the plane) acceleration, and furthermore the acceleration given in the file may be a combination of multiple accelerations (i.e. "total" and absolute acceleration vector)

So if the output is general acceleration (including engine thrust for example) or any variation thereof, it may not be quite the result needed.

G is normal acceleration minus (gravity as a projected vector) unless I'm mistaken which is entirely possible.

horizontal flight ->0G

upside down flight in a 2G radius loop, at top ->1G

same on either vertical side -> 2G

Alternatively it could be absolute G, which would mean in my examples, 1G for horizontal flight and 2G on a 2G loop verticals positions, and 1G at top.

I don't know about G meters in commercial planes (even if there are any), and I only surmise about G meters in military planes.

EDIT: OK I saw that you guys caught part of this issue already, after I made this reply, so ignore appropriately.

Jan, I assume he means "world up" as in normal to earth plane, (which is different than universe up which may be normal at pole and tangential at equator (and it could even get more complicated than this with celestial mechanics), I don't think it is used that way, too complicated and not necessary. So for all intents and purposes, "world up" is most likely normal to earth plane, and it's assumed the world is Euclidian (flat from a mechanical standpoint), and thankfully so. This however is still not normal to "plane's median horizontal" plane, which is what is needed.

The Euclidian assumption is a fair assumption for airplane mechanics, Coriolis effect and other gyroscopic effects are not fundamentally important for this use. (they may have a role in real world, but probably not that important that we need to simulate it, especially with no waepons)

And then there is "all accelerations included" which could be what the x,y,z is, so one may have to extract some from it.

If you already have the x,y,z aircraft mechanical parameters, then all you need is z accel (or get there from speed and vector orientation calculation) and then minus projected gravity, as I illustrated above.

So formula would be G= (Accelzaircraft - 9.81 *sin (angle between x aircraft and -z world))/9.81

Whatever component you don't have should be inferred from the one available.

• Thx Andre, I would have to know how each one of these variable is defined. Clearly the name is not "all inclusive" as we have 2 different one named accel or velocity, and they are not identical obviously.

Once we know which is which then we can calculate, there seem to be more than ample data to do so. But Jan and Admin also seem to have the proper info and may chime in with the answer.

It may require a transformation matrix, but I suspect it's done already in some of the data, so it may be simpler, like I posted.

• Official Post

If you want the acceleration in the pilot seat then I think my formula above is still correct, acceleration - gravity. For straight and level flight this gives you 1g. If you are inverted that gives you -1g. Straight up 0g on the z and 1g in x if the aircraft just barely manages to have enough thrust to maintain the current speed. That would also give you 2.0g in a 60° bank, you could go to 90° and not pull up and have 0g... That's what the A320 display shows if you pull full back on the stick, that is what the F18, F15, MB339, Extra and Pitts are showing on their instruments in the cockpit. Here the x component would indeed be the acceleration due to excess thrust.

The other option you have is the universe acceleration if I'm not mistaken for straight and level flight, just accelerating with full thrust this could be a vector like (5.34 2.35 -3.5), which is barely usable outside of Aerofly, unless you want to implement your own IRS.

To get from that to the local world up (When flying a 60° or 30° or 0° bank level turn it would always outputs 0g cause you are not starting to climb), you indeed have to use the normal vector of Aircraft.Position and then just to the dot product of these two vectors. But I'm not sure how this would be helpful, maybe if you want to program an autopilot that controls altitude but surely no instrument in the cockpit.

So formula would be G= (Accelzaircraft - 9.81 *sin (angle between x aircraft and -z world))/9.81

I wouldn't start messing with sin and cosine. You have all the matrices you need from orientation matrix (as shown by admin). Sin and cosine break for the Euler angles (pitch, bank, azimuth), e.g. for 90° straight up or down. The quaternion and matrix solution shouldn't though.

Regards,

Jan

• Jan,

Thanks.

I was just a bit overwhelmed with all the information given ``double g_factor = ( Aircraft.Acceleration - Aircraft.Gravity ).z / 9.81;``