Seemingly crazy (?) maths problem. Help wanted pls

So I’m trying to replicated the rotation of a vehicle in game to a hardware.
I’ve built a virtual prototype of the hardware:
image

This is a skeletal mesh where the roll mechanism rolls the entire pitch and yaw assembly. Then the Pitch mech will pitch the yaw assembly.

This thing works.

Problem is, I can’t get it to replicate the exact rotations of the vehicle.

Could somebody smarter than me figure out how to fix this?

PS: I know that’s a Jeep mesh in the UVSS. it’s irrelevant.

BUMP. As in, Bring Up My Post. pls tnx

Well, you can not copy paste Yaw Pitch and Roll. When rotating your UVSS you will have to translate your x y z rotation to a x y rotation because your “red” ring can not rotate around z as the other object . And it seems that you only rotate one axis when copying the orientation of the other mesh. I will have a look at an example :slight_smile:

Thanks! Could you provide an example of how to translate x y z to a x y, I can’t seem to find anything usable on Google. I can upload the project if you want to have a look at the blueprint code

Hi @Zarrar2802, not looking deeper into it, but just the first image you posted made me think of Gimbal Lock. Whether it is your problem or not, it is worth to be aware of the problems - an interesting phenomenon. Gyroscopes and Gimbal Lock - YouTube
Also searching for Quaternions may be useful here.
But if you make a Rotator from your source object and apply this one to the destination object, I think, that these should line up, provided both objects start with same basis.

Thanks! I’ll try that

Maybe a dumb question, but is your chopper not behaving “erratically” because of a collission with the floor? I mean, if you move it up on the Z-axis, so that is completely free of any collission, does it still move differently than your gyro?

The floor has no effect on the chopper. I had initially wired everything up thinking it’s all good and did a demo test by using a timeline to put the chopper in the most absurd positions it could randomly put it in and that’s when I noticed the errors.

Can you show your BP for applying the rotation to the heli ?

Sure, it’s quite simple. By the way, in the video I have this input being automated by a timeline. The multiply by -1 is just used to invert the pitch, roll, yaw values where necessary

The event tick for the heli takes the world rotation of the skeletal mesh sets it in a rotator variable inside the UVSS.

In the UVSS BP, the event tick is constantly reading the rotator variable, splitting it and then setting the respective values in float variables.

Which are read by the UVSS anim BP, to apply those rotations to the UVSS skeletal mesh bones respectively.


I think that’s all the primary code. I know I have the transform node’s settings correct because when I rotate one axis at one time while keeping other two at 0, all axis rotate perfectly.

Also, I should point out that my axis hierarchy is:
Roll → Pitch → Yaw

So roll is parent bone and Yaw is the end child bone

UE5_UVSS.zip (984.4 KB)
UE427_UVSS.zip (2.4 MB)

Does this help you? In the ShowCase map you can change the rotation of the BP_Origin to see the effects.

i’ll give it a test and get back to you asap

Integrating this code into my UVSS project will take some time, I tried to copy nodes from UE5 to UE4.27 and they broke. I see you built the UVSS prototype as separate meshes instead of a skeletal mesh and assembled them in the BP. I’ll try doing that to match your code and see how it goes

Will get back as soon as I’ve tested it!

OK so I replicated the entire code in UE4.27 including separating the meshes into separate parts and parenting them in a hierarchical order.
image

But I can’t seem to be getting the same rotation in my case.

The only differences are that the ref variable contains a skeletal mesh instead of static and pitch and rotation are fed into two separate static mesh components instead of one.

It seems the addition of another static mesh component (UVSS_Roll) in the mix is causing that abnormal roll on the UVSS. If I feed roll into the pitch static mesh component along with the pitch, it rolls fine.

Also, could you explain the math a bit so I could try to find out why it yaws in the opposite direction after crossing 180 during yaw and why it tries to go in the opposite direction after crossing 180 during pitch.

PS: On your implementation, it does the same thing on yaw and roll instead of yaw and pitch like in mine

1 Like

Eh, yes, it turns into the other direction after a certain amount. The idea behind it: Let the Z-axis of the outer ring have the same direction as the Z-Axis of the origin mesh. But in this case the rotation around Z is prohibted for the OuterRing, so just X and Y. To be able to do so I created the rotation matrix in common form (and got flash backs…studies…mechanical engineering). After that I set y (gamma) to be 0 and multiplied this with the direction vector of Z [0,0,1]. So now the rotated UP vector of the origin could be something like [0.9 , 0.5, 0.1] which equals [cos a *sin b , -sin a, cos a * cos b]. Simple equation I solved with the nodes you see in the project. Maybe this is all possible with quaternions or other things. The wrong rotation after a certain degree could maybe be solved by a simple change of sign.

wow that’s some math! I don’t understand it though. Sorry.

Would it be easy to use quaternions? I painstakingly when through installing this Blueprint library to expose quat functions to blueprints but don’t know if they’re of any use to me

After thorough consideration, I came to ask myself do I really need to replicate the complete rotation of the vehicle? I came up with a solution to replicate the Roll and Pitch as they were and only apply Yaw as acceleration to the UVSS. Since a physical prototype would have the user wearing a VR headset, they didn’t need to feel the complete rotation, only the centrifugal force caused by the rotation.

I also went ahead and implemented the elevation platform to provide the upward force felt by the user when the vehicle climbs in elevation. I also tried to implement the acceleration but the flying template uses “Add Actor Offset” to move the vehicle so I guess it’s practically teleporting the vehicle forward so velocity always comes back at zero.

I think I’m satisfied with what I have at the moment. Will forward this design to real engineers and let them poke fun at it.

Thank you to all of you who helped! Especially @L1z4rD89 !

Will mark this as answer to close the question.

1 Like

UE427UVSS.zip (2.5 MB)
For the sake of completeness

1 Like

Oh nice, I’ll have a look at this and get back asap

well I’ll be damned, you sir, are a math God. I tip my hat to you :tophat:
This is the solution. Yass.

Though I will admit that math gave me quite a scare.

But thank you so much! You have my eternal respect! <3

Quick question, would it be difficult to separate the outer ring component into two components to handle pitch and roll separately instead of one component handling both?

Yours
image

Mine
image

Yes. You split up the rotations. That is possible because you now have 2 angles extracted from a 3 angles rotation. You you just let the outer part rotate with the one angle and the big ring with the other angle.
UVSS.zip (2.8 MB)

1 Like