0
\$\begingroup\$

I'm using a 6-axis IMU (accelerometer + gyro) and collecting lateral and longitudinal acceleration (Ax an Ay) when in my car.

But this device (with IMU) is positioned at an angle when plugged into the OBD port of the vehicle. Therefore, the Ax and Ay are not zero to begin with. How do I transform Ax and Ay from IMU's reference frame to car's reference frame? Are yaw, pitch, and roll useful in making this transformation?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ If you can, please make your question more explicit. Right now, technically you have not asked a question. You have just made a statement. Is the main thing you want Ax and Ay in the reference frame of your car, or are you trying to get pitch/roll/yaw also or? \$\endgroup\$
    – user57037
    Jan 25, 2022 at 21:54
  • 1
    \$\begingroup\$ Do you know the angle of the IMU with respect to the vehicle frame of reference? \$\endgroup\$
    – user57037
    Jan 25, 2022 at 21:56
  • 1
    \$\begingroup\$ If you know the difference between the IMU reference frame and the vehicle reference frame you can just do an Euler rotation on the IMU data to align it virtually with the vehicle. \$\endgroup\$ Jan 25, 2022 at 22:12
  • \$\begingroup\$ @imnotarobot The difference you mentioned is yaw, pitch, and roll? I'm able to get those from the IMU's reference frame. Can you please give an example of the Euler rotation on the IMU data? Thanks. \$\endgroup\$ Jan 26, 2022 at 14:55
  • \$\begingroup\$ You mean like a dot product? Project every output from the IMU onto every coordinate axis represented as a basis vector of the vehicle. \$\endgroup\$
    – DKNguyen
    Jan 26, 2022 at 14:55

2 Answers 2

1
\$\begingroup\$

No time to write answer at the moment, especially if you know zero about vectors. So I'll leave this here. It is wordy but not difficult. Easier than calculus and Euler rotations but involves concepts you don't see as early as sin and cos but just takes a lot of book keeping of variables. You don't actually need sin and cos at all except one time during setup when you calculate your misalignment. After that you don't need it to perform your moment-to-moment transformations.

It is basically this but done for all three axis:

https://physics.stackexchange.com/questions/675998/how-do-i-get-the-total-acceleration-from-3-axes-in-negative/676038#676038

General approach is to make a three unit vectors in the coordinate system of your IMU, which we will call axis <i, j, k>, and have those unit vectors written in terms of ijk each points in the direction an axis of your vehicle coordinate system which we will call <x, y, z>.

Then dot product IMU outputs in vector form against each unit vector to project them in their entirety onto each axis of your vehicle coordinate system.

Since your vehicle unit vectors are orthogonal because you made them that way, then projecting IMU outputs get broken up completely with no components unaccounted for or missing.

Rotations about each axis follow right-hand rule.


BRIEF GUIDE AFTER YOU READ LINKED MATERIALS BELOW SO YOU HAVE SOMETHING MORE CONCRETE TO VISUALIZE IF YOU DON'T KNOW VECTORS AT ALL

So if your IMU ijk was aligned with vehicle xyz and then you rotated the IMU about the vehicle's x-axis by 45 degrees, then the xyz would be represented in the ijk coordinate system as unit vectors:

\$x: <1i + 0j + 0k> \$

NOTICE: We rotated about x-axis so i-axis still parallel with x axis so no change between those two axis, thus <1,0,0> for the x-axis unit vector when written in ijk coordinates.

\$y: <0i + \frac{1}{\sqrt 2}j - \frac{1}{\sqrt 2}k>\$

\$z: <0i + \frac{1}{\sqrt 2}j + \frac{1}{\sqrt 2}k>\$

NOTICE: Similarly, since we rotated about x-axis so i-axis still parallel with x axis everything on i-axis moves to x-axis and nothing on i-axis will get projected or distributed onto the y or z axis, thus the \$0i\$. However, j and k axis to get re-distributed to the y and z axis due to the 45 degree rotation thus the \$\frac{1}{\sqrt 2}>\$ of a 45 degree angle or triangle for both j and k.

Note how all unit vectors have a magnitude of 1, as they should.


Vectors represent magnitudes with directions in 3D space:

http://www.algebralab.org/lessons/lesson.aspx?file=Trigonometry_TrigVectorOperations.xml

Unit vectors are vectors with a magnitude of 1 so have a direction but when multiplied by other magnitudes impart a direction without changing the magnitude. They allow representation of a pure direction without inherent magnitude.:

http://www.algebralab.org/lessons/lesson.aspx?file=Trigonometry_TrigVectorUnits.xml

i, j, k are unit vectors along your cartesian coordinates. You can treat them kind of as letter variables multiplied with numerical scalar magnitudes to give directions to numbers. So you may do 1i+2j+3k to represent a vector. You may add or subtract two vectors written that way by adding or subtracting the terms as if i, j,k were variables. But you may not multiply or divide i, j, and k with each other. Dot and cross products are allowed for that (see later).


Dot Product is used to find the common component between two vectors. i.e. the parallel component The component that one vector projects onto the other. Dot product with a unit vector basically extracts the component of a vector for that unit vector http://www.algebralab.org/lessons/lesson.aspx?file=Trigonometry_TrigVectorDotProd.xml

Cross Product is complimentary to dot product. It finds the orthogonal component between two vectors. Cross product with a unit vector gives the component NOT along the direction of the unit vector (i.e. perpendicular): http://www.algebralab.org/lessons/lesson.aspx?file=Trigonometry_TrigVectorCross.xml

\$\endgroup\$
0
\$\begingroup\$

For anyone looking for a practical answer to this question instead of a lecture in vector algebra.

R. Bhoraskar, N. Vankadhara, B. Raman and P. Kulkarni, "Wolverine: Traffic and road condition estimation using smartphone sensors," 2012 Fourth International Conference on Communication Systems and Networks (COMSNETS 2012), 2012, pp. 1-6, doi: 10.1109/COMSNETS.2012.6151382. https://ravi.bhoraskar.com/papers/wolverine.pdf

Excerpt from the publication related to the question:

"When the phone is kept idle in some arbitrary orientation, the accelerometer shows some non-zero readings, giving illusion that it the phone is accelerating in those directions with the specified acceleration, which is actually not accelerating. This is because the force of gravity which acts vertically downwards, is factorized along the axes of the accelerometer. Similarly, even when the device is actually accelerating some direction, the readings does not corresponding to only the actual acceleration, but also includes this added factor of gravity. We need to calculate this force acting along the axes of the phone in that orientation and subtract it from readings. This can be done once we know the orientation of the phone. To transform the vector from reference coordinate system to target coordinate system, one method is to find the angles by which the axes of the reference coordinate system need to be rotated around each of the axes, to align with the axes of the target coordinate system"

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.