Hi there, I need to correct aberrant IMU euler orientation values occurring secondary to Gimbal lock.

I essentially have half the signal oscillating around the 0 degree mark and the other half around the 360mark. As true values will never exceed 180, I thought I could correct the output by reassigning all values > 360 to their original value subtracting 360. I have tried
Array Variable = yaw
yaw(yaw>180)=yaw-360
But this doesn't work, any have any ideas to correct this in an elegant way?

답변 (3개)

Hi Luckshman,
I understand that you are trying to limit your angle data to between 0 and 360 degrees. You may make use of the "mod" function to take all your data modulo 360. For example:
% raw data
>> x = randi(500, 10, 1)
x =
346
158
344
418
10
376
495
375
141
395
Corrected data by setting all angles > 360 to their corresponding values < 360:
y = mod(x, 360)
y =
346
158
344
58
10
16
135
15
141
35
This is also more robust than subtraction by 360 because for example if an angle is > 720 (i.e. two revolutions), the angle can still be brought back accordingly to the value between 0 and 360.
More information about MATLAB's "mod" function can be found below:
Best,
David
James Tursa
James Tursa 2017년 10월 18일
편집: James Tursa 2017년 10월 18일
The code you were using was not working because the rhs yaw was not indexed. E.g., to correct this
yaw(yaw>180) = yaw(yaw>180) - 360;
Thank you James and David! Both responses were very clear and helpful.

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

질문:

2017년 10월 16일

답변:

2017년 10월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by