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

3 visualizzazioni (ultimi 30 giorni)
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?

Risposte (3)

David Ding
David Ding il 18 Ott 2017
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 il 18 Ott 2017
Modificato: James Tursa il 18 Ott 2017
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;

Luckshman Bavan
Luckshman Bavan il 27 Ott 2017
Thank you James and David! Both responses were very clear and helpful.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by