Title: **surge, sway, heave**

Post by:**saebaryo** on **August 20, 2018, 03:58:08 PM**

Post by:

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

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

Title: **Re: surge, sway, heave**

Post by:**janaucarre** on **August 20, 2018, 06:39:40 PM**

Post by:

Hi, welcome here.

Title: **Re: surge, sway, heave**

Post by:**saebaryo** on **August 21, 2018, 12:40:26 PM**

Post by:

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:

I translated them for GpBikes as follows:

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?

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:

Code Select

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:

Code Select

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?