mason_safavy
The frequency of choice for your sensors is: as fast as you can (except you need to save some processing power for other tasks or energy consumption).
You do need to make sure the physical sensors are configured to update at the required frequency, and the kalman filter is configured to match that frequency. I don't know how to do that in the adafruit library, but in the original algorithm you have to set these constants in build.h
// sampling rate and kalman filter timing eg (25, 1), (200, 8), (400, 16), (500, 20), (600, 24), (800, 32)
// the MULTI-(B) 9-AXIS and AGM01 boards are able to sample the gyro sensor at 800Hz with Kalman filter rates depending
// on the processor speed and number of algorithms executing in parallel.
#define SENSORFS 100 // int32: frequency (Hz) of gyro sensor sampling process
#define OVERSAMPLE_RATIO 4 // int32: accel and mag sampling and algorithms run at SENSORFS / OVERSAMPLE_RATIO Hz
In order to give you an idea a regular chordata suit works at 100hz, and older versions worked at 50Hz. We need to process several sensors, but is you are using only one you might probably be able to go at higher rates.
mason_safavy I'm running on a Dual Core 64 MHz CPU with 1 MB of flash
It seems like a decent MCU, but the flash memory is a non volatile one which has little influence in the running performance of the MCU. Instead the RAM memory has a much higher incidence for processing scenarios like this one. But I guess that one will also be in the order of the MB as well so you should be good to go.
mason_safavy Lets imagine I fixed the sensor toward north with 45 degrees of pitch, generally the state quaternion should be : (0.94,0.00,-0.35,-0.00). Now I want the state quaternion to be for example (1.00,0.00,0.00,0.00) in the same state of the sensor. What should I do exactly?
Ok, I got it.
So you want transform that particular attitude of the sensor to the identity quaternion, to get "zero" rotation in that state.
by definition if you multiply the inverse of a quaternion by itself you obtain the identity quaternion. The inverse of a quaternion is obtained by inverting the vector part of it, so:
(0.94, -0.00, 0.35, 0.00) * (your real-time quat) = (your "resetted" real-time rotation)
Of course the sign *
in this case denotes quaternion multiplication, not element-wise one.
I hope that helps