AnsweredAssumed Answered

iNemo Lite code's interface?

Question asked by miller.danny on Jul 6, 2012
Latest reply on Aug 3, 2012 by miller.danny
I have the iNEMO Lite code for its Extended Kalman filter.  I have a board I made with an LSM303DLM and LSM330DL connected to the STM32F4 Discovery board for the IMU.

Is there any example?  It looks like it's a library, and I don't know how to call it or calibrate it.  Correct me if I'm wrong but I see 3 functions, an init, calc, and deinit function:
void iNEMO_AHRS_Init(iNEMO_SENSORDATA*    pSensorData,
                    iNEMO_EULER_ANGLES*  pAngle,
                    iNEMO_QUAT*          pQuat);

void iNEMO_AHRS_Update(iNEMO_SENSORDATA*    pSensorData,
                      iNEMO_EULER_ANGLES*  pAngle,
                      iNEMO_QUAT*          pQuat);

I'm not worried about collecting I2C samples, although it'd be nice to see what they sent it for sensor config.  I guess my first questions:
1.  Is there an example program, with a main(), anywhere?  Or did I just not look in the right place?  It'd also be good to see what config it gives to the accelerometers.
2.  What is the scale of the sensor data?  Once I get some I2C sample, I could give the accelerometer as 1=fullscale, I could change it to 1=1G, I could make it 1=1fps/s or =1ms/s.  The magnetometer has a #define EMS in gauss, so I'm guessing the incoming vectors should be in gauss.  But accel and gyro, what are they?  
Hmm there is a line:
#define     VAR_AX  (0.00096231f)     /*!< Accelerometer Variance on X-axis [m/s2] */ 
So I'm guessing accelerometer units are in m/s^2?
#define     VAR_MX  (0.000009f)          /*!< Magnetometer Variance on X-axis [(0.1*g)^2] */ 
So that reinforces the theory that the magnetometer is in gauss (g wouldn't be G-force).
The rate gyro would likely be in fraction of fullscale, deg/s, radians/s, or rotations/s.  I found a function "iNEMO_WrapAround" which looks to take in a radians argument, but that function isn't even used.

The SENSORDATA construct has a "ScaleFactor" and "m_fOffset" for all axes, but none of them are used in the code.
3.  I see there is a "m_fDeltaTime", that gets initialized to 0.01f.  So I guess that means 100Hz sample rate is intended there?  That's an available sample rate option for the accel/mag/gyro.  I guess I answered my own question there.
4.  I see the magnetic ellipse parameters are hardcoded in, which isn't valid from application to application.  There's a reference to for a calibration procedure, using some PC interface software.  How can this be done without that software?  Correct me if I'm wrong, but isn't this a matter of rotating it randomly for awhile, away from external magnetic materials, and looking for the highest and lowest magnetic values on the 3 axes?
5.  I see some mysterious state vector initialization:
   fSV[0] = 0.5375;
   fSV[1] = 0.04915; 
   fSV[2] = -0.0418;
   fSV[3] =  -0.8408;
   for (i=4; i < 7; ++i)
         fSV[i] = 0;

What does this do?  There's a commented-out version which lists these as all-zero.  I don't know the significance of these numbers, if they're something I need to derive from calibration or a mathematical reason for being what they are?
6.  What are these accel/mag "VARIANCE" figures?:
#define     VAR_AX  (0.00096231f)     /*!< Accelerometer Variance on X-axis [m/s2] */ 

Again, do they need to be calibrated or just accepted as-is?  
7.  Is the iNEMO app protocol openly documented?  It may be useful to use the iNEMO PC application, and it seems fairly simple to make STM32 code to feed the data out once the filter is working properly.  Could just send it through a UART and pick it up with a UART-USB dongle bridge and I see where the software takes in a COM port so it seems simple to set up.