Losing IMU Data
Investigation and Solution
This article discusses some of the problems I encountered whilst using a Raspberry Pi to read data from a complex sensor at approx 200Hz.
If you're short of time, just skip to the conclusions at the end of the article.
The system contains an IMU (an LSM9DS1), a sensor which provides acceleration, angular rate and magnetic field measurements. The IMU has a "Data Ready" output pin. It sets the pin to 1 when new data is available and clears it when the data is read. There's also an API call which provides the same information. This "Data Ready" output is connected to a GPIO input on the Raspberry Pi.
The positioning system spawns a process to gather data samples. I call this a "Data Pump".
The IMU produces samples at 230.8 Hz. i.e. once every 4.3 milliseconds.