Page 1 of 5

Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Mon Aug 19, 2019 10:34 am
by kiu
Hi,

I have got a Phidgets Spatial MOT1101_0 connected to Unity3d. The process was really nice and easy, thank you. Is there an equally easy way to retrieve a quaternion of the absolute rotation of the Phidget? I tried to convert the c# example, but the values are alle messy when applied to an object.

Any hint is appreciated! Thanks in advance!

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Tue Aug 20, 2019 10:05 am
by mparadis
While we're planning on adding quarternion support to future versions of VINT spatials (like we have with the 1044_1), the current ones do not support it.

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Fri Aug 23, 2019 4:32 am
by kiu
Thanks for the information. Is there an estimated timeline when the quaternion support will be available?

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Fri Aug 23, 2019 9:10 am
by mparadis
To clarify, when I say future versions, I mean actual different devices. The MOT1101 will not be getting quarternion support, the next models in the same line will. We don't currently have a timeline for when these new devices will exist.

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Fri Aug 23, 2019 3:47 pm
by Patrick
The C# spatial AHRS example contains the same algorithm as is embedded in the 1044_1 firmware, and shows how to get the same quaternion as a 1044_1 would output, but using the SpatialData event data.

https://www.phidgets.com/downloads/phid ... ows_Ex.zip

-Patrick

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Mon Sep 02, 2019 5:05 am
by kiu
Hi Patrick,

Thank you for providing this example. I have modified it to run in untiy3d (complementaryAHRS.cs didn't need any changes). However the data I'm receiving is nowhere near an absolute rotation when I'm applying the latestQuaternion to an objects rotation. (Keeps drifting and lerping)

It looks like complementaryAHRS is already trying to do some compensation, however it's not working very well. Is there a way to fine-tune it?

Sorry, I'm not very good with quaternions, any hint would be appreciated.

Best,
-martin

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Wed Sep 04, 2019 2:45 pm
by Patrick
Are you sure that you are using the data in Unity correctly. I'm not very familiar with Unity, but we have it working well here. The Phidget and Unity Quaternions are using different conventions. To update the Unity quaternion with Phidgets Spatial quaternion data we're doing this:

Code: Select all

    //Update the target orientation quaternion
    target.Set(
        -(float)e.Quaternion[0], 
        -(float)e.Quaternion[2], 
         (float)e.Quaternion[1], 
        -(float)e.Quaternion[3]);
-Patrick

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Mon Sep 16, 2019 4:03 am
by kiu
Thank you, @Patrick, I wasn't aware of the different Quaternion definition in Unity. I applied this and everything looks a lot more like it should.

Now, the rotation looks fine, however the spatials z-Axis (Unity Y) is always lerping back to a value between 200-235 degrees (euler) when I hold the device still. The only lerping in the code can be found in ComplementaryAHRS.scaleQuaternion, but due to my lack in proper understanding of quaternions I cannot quite find out how to fix this. :( Do you know why this might be happening?

Best,
-martin

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Wed Sep 25, 2019 6:45 am
by kiu
Hi Patrick, I posted a video of the behavior. As far as I can tell the Lerp on y is not coming from the device. Please help me understand :
https://share.icloud.com/photos/0LFiNUV ... land-Pfalz

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Posted: Wed Sep 25, 2019 12:14 pm
by Patrick
Looking at your data, I think you may have not calibrated the magnetometer.

This is especially important on the MOT1101 where the default mag values can be wildly out of spec. See: https://www.phidgets.com/docs/MOT1101_U ... alibration

I'd also suggest setting the gain_mag on the ComplementaryAHRS to 0.005 instead of the default 0.01.

After calibration, I'm getting good AHRS data from the MOT1101.

-Patrick