dlaidig / vqf

124 stars 23 forks source link

magEarth Calculation #13

Closed vincenttate13 closed 4 months ago

vincenttate13 commented 4 months ago

Hi @dlaidig, I have a question with respect to the rotation applied to the mag vector in order to yield magEarth.

From the updateMag function in vqf.cpp, magEarth is obtained by rotating the raw magnetometer measurement vector by the 6D orientation quat: getQuat6D(accGyrQuat); quatRotate(accGyrQuat, mag, magEarth);

If I understand the intention of this operation, why do you not need to invert accGyrQuat prior to applying it to mag? As an example, if you began with the IMU's local coordinate system in line with the global inertial coordinate system, then rolled the IMU +45 degrees, accGyrQuat should reflect a +45 degree rolled rotation. If the intention of this operation is to transform the mag vector into the inertial frame, would you not need to apply a -45 degree rolled rotation such that the magnetometer's local z-axis would realign with the global z-axis? Thanks!

dlaidig commented 4 months ago

I can assure that the operation is correct. Consider the following example:

I've also formulated a very similar example in https://depositonce.tu-berlin.de/items/a1990767-cacd-4749-bb74-5ade7ff16d12:

Screenshot 2024-02-22 at 14 25 38 Screenshot 2024-02-22 at 14 25 56
vincenttate13 commented 4 months ago

@dlaidig I see now, thank you very much for the clarification.