• Welcome to PiBoSo Official Forum. Please login or sign up.
 
May 21, 2019, 02:31:57 am

News:

GP Bikes beta15b available! :)


surge, sway, heave

Started by saebaryo, August 20, 2018, 03:58:08 pm

Previous topic - Next topic

saebaryo

Hello everyone, I recently discovered Gp Bikes.

I am currently using the demo version.

I would like to build a simulator with Arduino.

I interfaced in c# to the UDP plugin and I can get the data from SPluginsBikeData_t.

How do I calculate the values of surge, sway, heave?
What formulas should I use?

Thank you very much for your help

janaucarre


saebaryo

I found a link:
https://www.xsimulator.net/community/threads/how-to-write-a-game-plugin-for-simtools-2-0-api-documentation.9107/
where they explain how to make a simtools plugin.

in the example 1 the following formulas are used:


Roll_Output = ((.sngOrientation2 * 180 / 3.14159) - 90)
Pitch_Output = (.sngOrientation1 * 180 / 3.14159) * -1
Heave_Output = (System.Math.Cos(.sngOrientation2) * .sngAcceleration2)
Yaw_Output = (.sngOrientation0 * 180 / 3.14159)
Sway_Output = ((System.Math.Cos(.sngOrientation0) * .sngAcceleration0) + (System.Math.Sin(.sngOrientation0) * .sngAcceleration1))
Surge_Output = ((-System.Math.Sin(.sngOrientation0) * .sngAcceleration0) + (System.Math.Cos(.sngOrientation0) * .sngAcceleration1))
TractionLoss_Output = (((System.Math.Sin(.sngOrientation0) * .sngAcceleration0) + (System.Math.Sin(.sngOrientation0) * .sngAcceleration1)) * -1)


I translated them for GpBikes as follows:


Sway = Math.Cos(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationX + Math.Sin(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationY;
Surge = Math.Cos(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationY - Math.Sin(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationX;
Heave = Math.Cos(msg.m_fRoll * 3.14159 / 180) * msg.m_fAccelerationZ;
TractionLoss = ((Math.Sin(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationX) + (Math.Sin(msg.m_fYaw * 3.14159 / 180) * msg.m_fAccelerationY)) * -1;


Unfortunately, the result does not reflect sway, surge and heave that I expect from GpBikes.

Only heave seems to mirror the physics of the game.

I think there's something wrong with Yaw.

I do not know if it is better to turn G into m/s2.

What can be the solution?