Hello all,

I’m trying to make a data logger for a motorcycle, currently I’m only interested in the longitudinal acceleration (Acceleration/Brake) and lean angle (Right/Left)

I’m using an Arduino 101 board for this.

Using the example “Arduino/Genuino 101 CurieIMU Orientation Visualiser” as base and from there I can easily obtain the lean angle (Pitch in the code) and adding some lines, the acceleration.

The issue is the following.

I can not assure a location in the motorcycle that allows me to place the board in such a way that the X axis is aligned with the motorcycle, and thus, the readings are not correct.

I have a code that “calibrates” the board position, once activated this code takes one reading of the gravity direction (I will call this G’ onwards) with the motorcycle completely vertical and one with the motorcycle at a certain angle to the left side ( I will call this L’ onwards").

With these two readings it creates a “rotation axis” (I shall call this X’ onwards) making the cross product of the readings and normalizing it.

X’ = G’ x L’ and then X’ = X’ / |X’|

Making another cross product between X’ and G’ I complete the coordinate system with Y’

Y’ = G’ x X’ and then Y’ = Y’ / | Y’|

With these vectors I can create the transformation matrix between the board axis and the motorcycle axis, the rows of this matrix are X’ , Y’ and G’ (normalized vectors all).

The data I am looking for to obtain are the acceleration and rotation along X’ axis.

What I’m stuck with is how to transform the readings from the board axis to the motorcycle axis.

I have been reading about quaternions, and come with the following.

If I have the IMU readings on board axis (Q0) and I have the transformation matrix as quaternion (QT), if I make the quaternion product QT x Q0 I will be applying the coordinate transformation to the rotation vector and thus, I can use Madgwick filter to obtain the rotation in X’.

This is build up in my mind, but I would like to confirm the quaternion maths, since it is a field I’m not acquainted with.

Thanks, Manuel.