simcodersdotcom / headshake

Source code of the HeadShake plugin for X-Plane
https://www.simcoders.com/headshake
GNU General Public License v3.0
39 stars 12 forks source link

added damping sine wave to model nose wheel bump on touchdown #32

Open lennox-xonnel opened 3 years ago

lennox-xonnel commented 3 years ago

This is a draft aiming to add the bump effect when the nose wheel touches down.

I added a damping sine wave to model the nose wheel bump on touchdown. Since I'm not a real life pilot, I'm not quite sure how big the effect is and which variables might affect it (I imagine many, like wheel pressure and nose down speed, if at all possible to be determined via a dataref, tho we might want to limit the model to a few). For this reason, every damping function parameters are exposed as dataref so that they can be modified and tested in game. It would be nice if someone with real life experience could try it and tell me what parameters feel the best.

The function has the form:

y(t) = - A e^-(Lt) sin(2 PI F t)

where:

At the moment, the nose wheel touchdown check is performed assuming the nose wheel is the first in the sim/flightmodel2/gear/on_ground array dataref, but we might want to perform a better check, testing the position of each wheel using the sim/aircraft/parts/acf_gear_znodef in order to establish which wheel is the furthest forward.

All code is unfinished and unpolished, everything will be cleaned up in future commits.

Closes #28

nico87 commented 3 years ago

In real life the view does not shake, of course, but you get the feeling of the wheel touching down. I believe the best feeling is given by a vertical shacking with a very little roll of the view (as as damped sine wave). The hardest the impact of the front wheel, the strongest should be the effect.

lennox-xonnel commented 3 years ago

Unfortunately, judging from the datarefs, there seems to be no way to get the vertical speed of the nose wheel, but I'm new to XP plugin development so I could be wrong.

As for the "vertical shaking with a very little roll of the view" do you mean that, apart from the movement I already implemented on the vertical axis, it would be nice to have a roll on the longitudinal axis?

nico87 commented 3 years ago

In the datarefs there's no direct reading of the vertical speed of the nose wheel but in other plugins I just used the pitch speed to detect this kind of movement. A quick change of pitch means that the nose wheel is going to hit the ground pretty hard.

With "vertical shaking with a very little roll of the view" I mean a roll along the longitudinal axis, as you mentioned.

lennox-xonnel commented 3 years ago

Understood, I'll try to implement it! Would you mind pointing me in the right direction with the dataref I can use to gauge the pitch speed? Thank you

nico87 commented 3 years ago

I would use "sim/flightmodel/position/true_theta" to get the current pitch. In the flightloop you can get the elapsed time. Tracking the change of pitch in time you get the pitch speed. :-)

lennox-xonnel commented 2 years ago

I added the requested features, if you could try it and let me know it would be great. When everything will work as expected, I'll tidy up the code.