Relative rotation between two IMU's

21 Ansichten (letzte 30 Tage)
hichem mestiri
hichem mestiri am 8 Jun. 2020
Kommentiert: Omar Ahmed am 16 Sep. 2024
I'm trying to obtain the relative rotation between two IMU's.
In order to verify the quality of the orientation delivered by the IMU (quaternions), I attached both IMUs to a rigid body (bar) but placed in a different orientation.
I recording of 1 min data for a rotation of the system (2 IMUs attached to the bar) in slow motion.
Both IMUs should give the same orientations after aligning their frames or in other words the relative rotation between both should be constant.
So, to align the frames, i first take q_start of both (imu1 and 2) in the first 5s when the system was at rest on the table:
q_start1 = mean(Q1(t0->5s));
q_start2 = mean(Q2(t0->5s));
Now in order to express their frames in world frame:
Q1_w = Q1 * Inverse(q_start1);
Q2_w = Q2 * Inverse(q_start2);
And to obtain the relative rotation between them:
Q_relative_w= Inverse(Q1_w) * Q2_w;
But Q_relative was not constant but if I switch the 3rd and – 2nd component of Q2_w that’s mean:
Q2_w = [w,x,y,z] -> Q2_w_new = [w,-y,x,z]
Then i apply: Q_ relative_w_new = Inverse(Q1_w) * Q2_w_new;
I obtain a relative constant Q_ relative_w_new.
My Question:
Where is my error in the calculation or if this calibration makes sense at all?
If not how can I otherwise align the frames?
  2 Kommentare
Image Analyst
Image Analyst am 8 Jun. 2020
Hard to visualize without some diagram to explain things.
James Tursa
James Tursa am 8 Jun. 2020
Bearbeitet: James Tursa am 8 Jun. 2020
The very first thing you need to do is verify the convention of the quaternions you are using. Are you sure they are scalar-vector order as you seem to be assuming? And are you sure they represent coordinate system transformation quaternions? Are these quaternions an output of the IMU or are you constructing them manually somehow?
Side note: You should normalize your mean quaternions before using them downstream. E.g.,
q_start1 = mean(Q1(t0->5s)); q_start1 = q_start1 / norm(q_start1);
q_start2 = mean(Q2(t0->5s)); q_start2 = q_start2 / norm(q_start2);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

James Tursa
James Tursa am 8 Jun. 2020
Bearbeitet: James Tursa am 8 Jun. 2020
Assuming the coordinate frames are as follows:
ECI, the world frame
BODY1, the IMU1 body frame
BODY2, the IMU2 body frame
Examining your quaternion arithmetic:
q_start1 = mean(Q1(t0->5s)); % ECI->BODY1_t0
q_start2 = mean(Q2(t0->5s)); % ECI->BODY2_t0
% (NOTE: The above should be normalized)
Now in order to express their frames in world frame:
Q1_w = Q1 * Inverse(q_start1); % ECI->BODY1_t * inverse(ECI->BODY1_t0) = ECI->BODY1_t * BODY1_t0->ECI
Q2_w = Q2 * Inverse(q_start2); % ECI->BODY2_t * inverse(ECI->BODY2_t0) = ECI->BODY2_t * BODY2_t0->ECI
And to obtain the relative rotation between them:
Q_relative_w= Inverse(Q1_w) * Q2_w; % inverse(ECI->BODY1_t * BODY1_t0->ECI) * (ECI->BODY2_t * BODY2_t0->ECI)
Expanding that last one:
(ECI->BODY1_t0 * BODY1_t->ECI) * (ECI->BODY2_t * BODY2_t0->ECI) =
ECI->BODY1_t0 * (BODY1_t->ECI * ECI->BODY2_t) * BODY2_t0->ECI =
ECI->BODY1_t0 * (BODY1_t->BODY2_t) * BODY2_t0->ECI
So, you have what I think you are after, BODY1_t->BODY2_t, wrapped inside of other ECI to BODY stuff. I think what you should be after is just the BODY1_t->BODY2_t stuff. E.g.,
q_t0 = inverse(q_start1) * q_start2; % inverse(ECI->BODY1_t0) * ECI->BODY2_t0 = BODY1_t0->BODY2_t0
Then calculate this downstream:
q_t = inverse(Q1) * Q2; % inverse(ECI->BODY1_t) * ECI->BODY2_t = BODY1_t->BODY2_t
And see if all of the q_t calculations seems to be fairly constant.
For a discussion of MATLAB quaternion conventions (you need to know this in order to do the quaternion arithmetic correctly), see these links:
  14 Kommentare
宇 梁
宇 梁 am 9 Dez. 2021
it did has Effect on my work with ICM20948 also.but how can I use this work on real time calculating?I noticed that I have to use all the data to calculate the alignment.q which mean that I have to sample all the data before I calculate the Q_diff
Omar Ahmed
Omar Ahmed am 16 Sep. 2024
@James Tursa I have the same Issue. I proceed with all steps you provided before But I got this Curve. The data that I collected is TUG (the subject supposed to sit up walk for 3m and return back and sit down)
Does these attached images make sense ? I don't think so. What I'm trying is I want to get the relative angle between two IMUs and then after getting the relative angle I can multiply it with accelerometer or magnetometer or gyro scope of one IMU to get the same data of the second IMU.
could you help me in this ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by