cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX "nan" values after a while on Discovery kit IoT node

Walter Lucetti
Associate III

Hi,

I'm testing the MotionFX library with the Discovery Kit IoT node [B-L4S5I-IOT01-A] and I have a problem: randomly the sensor fusion algorithm "explodes" and I can only get only "nan" values for all the `MFX_MagCal_output_t` values, Gyro Biases included.

What can be the cause of this behavior?

Following my initialization code:

int32_t initMotionFX()
{
  char lib_version[MFX_STR_LENG];
  MFX_knobs_t iKnobs;
  /* Sensor Fusion API initialization function */
  MotionFX_initialize();
 
  MotionFX_GetLibVersion(lib_version);
 
  MotionFX_getKnobs(&iKnobs);
  iKnobs.LMode = 1;
  iKnobs.gyro_orientation[0] = 'n';
  iKnobs.gyro_orientation[1] = 'w';
  iKnobs.gyro_orientation[2] = 'u';
  iKnobs.acc_orientation[0] = 'n';
  iKnobs.acc_orientation[1] = 'w';
  iKnobs.acc_orientation[2] = 'u';
  // Note: the magnetometer is rotated by 180° respect to the IMU
  iKnobs.mag_orientation[0] = 's';
  iKnobs.mag_orientation[1] = 'e';
  iKnobs.mag_orientation[2] = 'u';
 
  MotionFX_setKnobs(&iKnobs);
 
  // ----> Experimental init bias value
  // Note: to be replaced by flash memory reading
  init_gyro_calib[0] = 0.08; 
  init_gyro_calib[1] = 0.02;
  init_gyro_calib[2] = 1.02;
  MotionFX_setGbias(init_gyro_calib);
  // <---- Experimental init bias value
 
  MotionFX_enable_6X(MFX_ENGINE_ENABLE);
  MotionFX_enable_9X(MFX_ENGINE_ENABLE);
 
  return 0;
}

13 REPLIES 13

Thank you for checking the code.

I have a log application that I can use to save the data. I only need to modify it to retrieve also the mag raw and biases.

I will share the data as soon as they are ready

@Miroslav BATEK​ you can download the log here in CSV format: https://www.dropbox.com/s/e5mvywc2evehkxr/20210226_155357-SensorsDataCompare.zip?dl=0

The columns `MFX_MAG_CALIB_IN_TS`, `MFX_MAG_CALIB_IN_X`, `MFX_MAG_CALIB_IN_Y`, `MFX_MAG_CALIB_IN_Z`, `MFX_MAG_CALIB_OUT_X`, `MFX_MAG_CALIB_OUT_Y`, `MFX_MAG_CALIB_OUT_Z` contain the data exactly as they are used in the firmware, without any kind of conversion:

TS in msec

MFX_MAG_CALIB_IN in µT/50

MFX_MAG_CALIB_OUT in µT/50

@Miroslav BATEK​ Thank you for your support. I finally found the issue. The "nan" problem was generated by the "timestamp overflow".

In the IMU Task, I have a code that handles the overflow and recast the timestamp on a `uint64_t` variable, but there was a wrong comparison between "raw" timestamp and "timestamp*25".

I fixed it and I left the board running for more than 9 hours without any issue.

Thank you very much

Walter

I'm glad you have found the issue.