Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Supporting Visual Studio on Windows
Post Reply
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Post 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!
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Post 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.
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

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

Post by kiu »

Thanks for the information. Is there an estimated timeline when the quaternion support will be available?
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Post 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.
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

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

Post 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
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

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

Post 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
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

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

Post 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
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

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

Post 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
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

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

Post 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
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests