Software Architecture for using IMU (inertial measurement unit)

I picked up an US$8.50 MPU-9250 9-axis IMU (inertial measurement unit) for my Raspberry Pi 3B based GoPiGo3 robot this week. Connecting it up electrically was very simple, and I quickly got a basic “directly read the accelerometers, gyros, and mags over I2C” working.

This IMU has two features that are more complex: data filtering, and a FIFO readings buffer.

I have not found documented Python examples for these two features.

Even after finding or figuring out these, I will still need to package the features up for asynchronous processing, with a further complication that I don’t have an interrupt line connected.

I’m thinking I need an IMU process (not threaded, true multi-processing) which

  1. configures a known sample rate, and then
  2. periodically reads the FIFO
  3. tags each sample with a time or time since “zero point”, then
  4. creates an integrated “pose” (zero point referenced X,Y,Z, heading, speed), and
  5. stuff poses into a Queue that was passed from the parent process
  6. and also handles periodic correction against drift when the bot stops moving
    so that my robot can periodically pop the poses when it wants to know where it is
    (Disclaimer: I know the errors build quickly. I want to see what is possible.)

This is looking positive: https://github.com/MarkSherstan/MPU-6050-9250-I2C-CompFilter

1 Like