Question about Translating a Quaternion into Pitch and Roll for a Motion Simulator

Good morning! I have a question about Quaternions (spooky spooky)

I’m working on a research project using a motion simulator that has two 360 degree axes of rotation: it can pitch all the way around, and roll all the way around.

Here’s a bad diagram, showing both motors as the pitch (which rolls the arm all the way around), and roll, which rotates the cockpit:

5849032--621217--upload_2020-5-14_13-28-54.png

Essentially, we need to break down a player transform into pitch and roll angles that will smoothly simulate the movement of the player. The problem is that every single approach we’ve taken so far has caused different problems at different angles, usually having a series of movements that cause the angles to move quickly or unexpectedly.

To make the roll feel accurate, we only want it to move when the player actually rolls, and we want the pitch to only move when the player pitches. The motion should roughly approximate the tracked Transform’s motion as it rotates freely throughout space.

Here are some approaches we’ve tried so far and had troubles with:

  • Taking the Euler Angles directly: causes many issues when doing a full pitch rotation with little to no roll, including the roll flipping all the way around during the loop.

  • Locking the rigidbody of the player’s movement axis: we’re using a third-party combat kit that rotates the rigidbody and the transform unpredictably, so we can only track the transform’s change in rotation, not the rigidbody’s torque, to mimic the movement on a test rig.

  • Tracking the change in rotations using quaternions and breaking them down into EulerAngles, which are recorded as separate pitch and roll values: this causes the player to eventually become off-sync with the test rig, meaning that the player can be upside-down while the actual simulator is not.

I have also checked a dozen threads both in these forums and stackoverflow for different approaches that break down the quaternion using some odd math, but unfortunately they usually present the same problems as above, where the movements aren’t accurate to what we expect.

We have full freedom of movement in the game, because the player is in a spaceship dogfighting. If anyone has any ideas for approaches that “feel” correct (rolls and pitches when the player rolls and pitches, does not get off sync) please let me know!

tl;dr: break down a transform’s rotation into pitch and roll values without having those values change suddenly, and have them seem accurate to the movement of the transform for a player in a motion simulator

Thank you!!

If you implement it with explicit linear control of each axis of freedom, then you want to have a parented multi-transform hierarchy that mimics your mechanical setup:

BaseFixture
—PivotAroundY
------PivotAroundX
---------ActualContainerForEverything

You can swap around above. This would be if you are mimicking actual motor actuators on each axis.

ALTERNATELY, you can just apply local torques to a single Rigidbody. This is how I handle it in my Jetpack Kurt Space Flight game. Local torques are applied according to the players yaw, pitch and roll inputs. By the time the actual torque code happens, each input has been filtered and conditioned to range from -1 to 0 to +1, and gets scaled according to the authority of each axis of motion (yaw authority, pitch authority, roll authority).

This is a pure rate control that would mimic being inside the Lunar Excursion Module in freefall, with manual reaction jet controls on each of the three orthogonal axes. Here is how those torques are applied:

        rb.AddTorque( rb.transform.right * pitch * pitchAuthority);
        rb.AddTorque( rb.transform.forward * roll * rollAuthority);
        rb.AddTorque( rb.transform.up * yaw * yawAuthority);

That’s it for this type of fully-free axis-independent rate control. rb is the Rigidbody reference.

You can try it out yourself here:

Appstore: ‎Jetpack Kurt on the App Store
GooglePlay: https://play.google.com/store/apps/details?id=com.plbm.jetpack

External TestFlight link: TestFlight - Apple

Youtube playlist: https://www.youtube.com/playlist?list=PLTzufax_A179M51bQgMFDJ7y9Gjp9kOVR

Itch.io: Jetpack Kurt Space Flight by Kurt Dekker

Simmer.io: SIMMER.io