cancel
Showing results for 
Search instead for 
Did you mean: 

Touch Controllers - Angular Velocity? (Unity 5.4)

eddietree
Honored Guest
Hi there, this is probably a silly question, but I am having a bit of trouble figure out the exact Unity C# implement required to convert Oculus' angular velocity to Unity.

from: Oculus SDK's angular velocity (quaternions) 
to: Unity's RigidBody angular velocity (euler angles)

Has any been able to do this successfully? I tried converting it to axis-angle, then to Euler, but that math doesn't seem to work out.

Any help would be appreciated 🙂
10 REPLIES 10

ajkolenc
Honored Guest
I'm also having a hard time figuring out how to convert the angular velocity. My intuition says that the value should be the rotation from the previous frame's rotation to the current frame's rotation (perhaps smoothed over a few frames), but it's conceptually difficult to convert that value into the global Vector3 that Unity expects. Any support on that front would be great.

mfmf
Oculus Staff
Hey folks: sorry, that call is currently broken, and gives incorrect results. I'd recommend you not use it for now. We'll fix it in an upcoming version, and we may move to using eulers instead of quats for the result.

eddietree
Honored Guest
mfmf said:


Hey folks: sorry, that call is currently broken, and gives incorrect results. I'd recommend you not use it for now. We'll fix it in an upcoming version, and we may move to using eulers instead of quats for the result.


Thank you Mfmf. I could never get the result i wanted, and thought i was going crazy. I'm very glad to hear that it is still wip.

And yes, I think all us unity devs would definitely appreciate it being Euler instead so that it maps directly into Unity's angular velocity physics.

ajkolenc
Honored Guest
Just for reference, I was able to get pretty good results from this code:

public Vector3 GetAngularVelocity(Quaternion currentRotation, Quaternion lastRotation){
   Quaternion rotation = Quaternion.Inverse(lastRotation) * currentRotation;
   Vector3 euler = rotation.eulerAngles;
   if (euler.x > 180){
      euler.x -= 360f;
   }
   if (euler.y > 180){
      euler.y -= 360f;
   }
   if (euler.z > 180){
      euler.z -= 360f;
   }
   return transform.rotation * euler;
}

This can be plugged into rigidbody.angularVelocity directly, and assumes currentRotation is the rotation from this frame and lastRotation is the rotation from the previous frame. You could probably smooth it over several frames, but I was surprised how well this worked with just the two frames of data.

pepe_q
Honored Guest

mfmf said:

Hey folks: sorry, that call is currently broken, and gives incorrect results. I'd recommend you not use it for now. We'll fix it in an upcoming version, and we may move to using eulers instead of quats for the result.


Sorry mfmf would you mind to just change the angular velocity it into a standard angular velocity vector? Either euler and quaternion has a -PI, +PI range limitation (that is my main current problem using OVRInput.GetLocalControllerAngularVelocity())

https://en.wikipedia.org/wiki/Angular_velocity

eddietree
Honored Guest
Thank you very much yall.


mfmf said:

Hey folks: sorry, that call is currently broken, and gives incorrect results. I'd recommend you not use it for now. We'll fix it in an upcoming version, and we may move to using eulers instead of quats for the result.


@mfmf  - any idea when this angular velocity fix will go live?

pepe_q
Honored Guest


eddietree said:

Thank you very much yall.


mfmf said:

Hey folks: sorry, that call is currently broken, and gives incorrect results. I'd recommend you not use it for now. We'll fix it in an upcoming version, and we may move to using eulers instead of quats for the result.


@mfmf  - any idea when this angular velocity fix will go live?



Ah eddie I just got aware it was you! I'm pepe from Q. I'm trying to implement a frisbee throwing by touch controller (you use a weapon for your frisbees right?), and the problem I found is that quaternion suddenly wraps the angular velocity negative value in rads/second. It's actually quite easy to get more than 2PI rads/sec with your hand! I tried calculating the velocity from the rotations myself but I get a lot of value jittery (especially at high speeds) so I thought the OVRInput was the best.
Best regards!

eddietree
Honored Guest
Curious if this will be fixed before it goes live on Dec 6th? 🙂

MikeF
Trustee
Any progress on this?  seems to still have issues in the current release