Gimbal lock from sensor fusion

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Gimbal lock from sensor fusion

Jump to solution
5,336 Views
leo_lau
Contributor II

Hello, I am new to NXP. Currently, I am playing with NXP Sensor Fusion Toolbox with FRDM-STBC-AGM01. I have flashed the example Kinetis Binary using the Toolbox. The magnetometer is calibrated and saved to flash. Gyro Stabilized Compass is selected in algorithm tab.

 

But when I lift the the board to vertical (pitch to ~90)and rotate the board left and right, roll and compass increase/decrease together.

 

I know the Euler angle is converted from rotation matrix and is used for display only. Also, the rotation matrix is converted from quaternion in Kalman filter. 

 

My questions:

1. Why gimbal behavior appeared? Isn't quaternion immune to gimbal Lock? 

2. How to solve this gimbal lock problem?

 

Thank you.

Labels (1)
Tags (2)
0 Kudos
1 Solution
5,236 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hello Leo,

please see a reply from the application engineer.

 

DESCRIPTION

Please refer to section 1.7 and 2.4  in AN5017( attached) which explains the gimbal lock and mathematics at gimbal lock position.  From customer video, I can see him rotated PCB around the vertical axis at 90 degree pitch, the image would be following his rotation if the mag calibration worked good.   The compass data may jump due to compass  discontinuity at the gimbal lock position as board may change between face up and face down, but both roll and compass are not locked or oscillate randomly.  

With Best Regards,

Jozef

View solution in original post

0 Kudos
7 Replies
5,320 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hello Leo,

 

I have tested the FRDM-STBC-AGM01 in the Freedom Sensor Toolbox and you are right, the gimbal lock appeared, when the board is lifted 90 degrees in pitch direction. 

Unfortunately the magnetometer in the FXOS8700CQ is not immune to the gimbal lock. The gimbal lock is due to the limitation of the Euler Angles calculation method. Please see this link: https://www.youtube.com/watch?v=q0jgqeS_ACM 

With Best Regards,

Jozef

0 Kudos
5,312 Views
leo_lau
Contributor II

Thanks for your reply. 

 

Unfortunately the magnetometer in the FXOS8700CQ is not immune to the gimbal lock. 

----------------------

I've been going through all the algorithm in NXP Sensor Fusion Toolbox. Gaming Handset algorithm that does not use magnetometer also shows gimbal lock symptom. Which means the problem is nothing about the magnetometer. It should be the algorithm itself.

 

The gimbal lock is due to the limitation of the Euler Angles calculation method.

------------------

 I have checked NSFK_Prod_UG.pdf which stated that: 

"Rotation matrices have the advantage of always being unique. Euler angles are subject to gimbal lock and should not be used for internal calculations (only input/output of results). " 

In addition, I have a glance at NXP sensor fusion which use quaternion in most of the calculations. Isn't quaternion immune to gimbal Lock? 

 

Is this a known issue for NXP sensor fusion? Finally, how to solve this gimbal lock problem?

0 Kudos
5,288 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hello Leo,

please see an answer from an application engineer I have contacted. 

 

DESCRIPTION

I am not sure if my understanding is correct, does customer think on the 90 degree vertical pitch position, the roll and compass should not change, otherwise, he think this is gimbal lock?  From my thoughts,  the concept is just opposite.  As customer mentioned, all 3 angles are calculated from rotation matrix, at 90 degree pitch, the sensor fusion still gives correct compass heading which aligned with the board direction.

With Best Regards,

Jozef

0 Kudos
5,280 Views
leo_lau
Contributor II

I think I should explain this problem with a video for a better understanding of the issue.

Can you show this video to the engineer please?

 

-----------------

This video consists of two parts. First, pitch is stable when roll ~-90 degree.

Second, roll angle does not look right when pitch approach 90. 

Is it gimbal lock?

0 Kudos
5,237 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hello Leo,

please see a reply from the application engineer.

 

DESCRIPTION

Please refer to section 1.7 and 2.4  in AN5017( attached) which explains the gimbal lock and mathematics at gimbal lock position.  From customer video, I can see him rotated PCB around the vertical axis at 90 degree pitch, the image would be following his rotation if the mag calibration worked good.   The compass data may jump due to compass  discontinuity at the gimbal lock position as board may change between face up and face down, but both roll and compass are not locked or oscillate randomly.  

With Best Regards,

Jozef

0 Kudos
5,188 Views
leo_lau
Contributor II

I had a misunderstanding with gimbal lock and everything is clear now.

Thank you for clarifying my problem.

0 Kudos
5,086 Views
venkidravid
Contributor II

Hi Mr Leo,

 

I am facing the same problem.. But i didn't understand the solution...

1st Problem is..

I rotated the board in Pitch direction... when pitch is beyond 75 Deg then Roll & Yaw increasing substantially (>45 Deg in each ) even though i didn't rotated board in Roll & yaw  direction.. What is the root cause for this? How to Solve this problem?

 

2nd Problem is...

I have done magnetometer 12 parameter calibration and I got magnetic field strength B= 42 uT.

But when i rotated the board in different orientations at the same location B (computed as norm from magnetometer calibrated readings) is varying around 32uT to 52uT .. Since the location is not changed B shouldn't change but it is changing at the same location...

What is the reason for this?

Is this due to imperfect calibration due to noise in instant reading of magnetometer sensor  FXOS8700CQ?

How to solve this problem?

 

Any help in this greatly appreciated.

 

Thank you,

Venkat.

 

0 Kudos