We are creating a device based on a ESP32 and an ICM20948, using 4 actuators to physically level out platforms.
The actuators are activated based on the Roll and Pitch that is calculated from the output of the ICM20948.
For the calculation of the Roll and Pitch, we “borrowed” code from the internet (https://en.wikipedia.org/w/index.php?ti … rce_code_2 ), incoorporated in the examples by @PaulZC as I understand)
We are technically schooled but no mathematicians and do not really understand what it’s doing … but its working
The actuators are on a well known location on the platform, so we know that if i.e. Roll = 10 that we need to extend the forward and backward actuators on the right of the platform to get the Roll to become smaller.
The problem now arrises that the way that our device is mounted on the platform can vary between installations, the ICM will not always be mounted parallel to the top surface of the platform, but can be mounted in any orientation (we can assume that it will only be 90 degree rotations, so the Roll or Pitch axis can point forward, left, backwrd, right, up or down in regards to the platform.)
Our question is how can we add a configuration specifying the mounted orientation, and (more importantly) use that configuration to get the right Roll and Pitch angles of the platform to steer the correct actuators.
Any help or reference to other sources would be welcome.
Thanks!
I posted this question as an issue on the ICM_20948 github and PaulZC was kind enough to point out de direction of the solution, but I still need some more help in implementing this. (See https://github.com/sparkfun/SparkFun_IC … /issues/66)
So i could get a quaternion describing the physical mounting of the ICM but im still not sure how to apply this quaternion on the quaternion that comes from the ICM (before converting it to Euler angles). Can somebody help me with that?
Also, would mounting the ICM differently have any effect on the accuracy of the retrieved values? I can i.e. imagine that the magnetometer will be working differently if its set at a 90 degree angle… ?