5.6. Inertial sensors
The 3pi+ 32U4 includes on-board inertial sensors that allow it to determine its own orientation by implementing an inertial measurement unit (IMU). The first chip, an ST LSM6DS33, combines a 3-axis accelerometer and 3-axis gyro into a single package. The second chip is an ST LIS3MDL 3-axis magnetometer.
Level shifters built into the main board allow the inertial sensors, which operate at 3.3 V, to be connected to the ATmega32U4 (operating at 5 V). The sensors, level shifters, and I²C pull-up resistors are connected to the SDA (digital pin 2, or PD1) and SCL (digital pin 3, or PD0) pins on the AVR by default, but they can be disconnected by cutting the surface-mount jumpers labeled “SDA” and “SCL” under “IMU” on the board to allow those pins to be used for other purposes.
We recommend carefully reading the datasheets listed above to understand how these sensors work and how to use them.
Using the sensors
The Pololu3piPlus32U4 library (see Section 7) includes functions that help configure and read the inertial sensors. The library includes some example programs that demonstrate how to use the sensors.
For advanced applications, you can instead use some of the dedicated libraries that we have written for these sensor chips; these include our LSM6 Arduino library, LIS3MDL Arduino library, LSM303 Arduino library, and L3G Arduino library. The 3pi+ 32U4 control board uses the same inertial sensor ICs as our MinIMU-9 v5, so Arduino software written for the MinIMU-9 (such as our AHRS example) can also be adapted to work on a 3pi+ 32U4.
Notes on the magnetometer
Please note that the magnetometer on the 3pi+ 32U4 can be affected by magnetic fields from the 3pi+ itself. These include magnets in the motors and encoders, electrical currents through the board, and hard iron distortions from metal (probably mostly from the batteries). The magnetometer is positioned as far away from the motors as possible to avoid interference from them, but hard iron distortions can still influence the readings significantly, making it difficult to accurately determine the 3pi+’s absolute heading based on the raw magnetometer data.
This post on the Pololu forum details a technique for correcting for hard iron distortions, making it possible to use of the magnetometer as a compass for navigation in environments that are not dominated by magnetic interference. (It is written about our Balboa 32U4 robot, but the same principles apply to the 3pi+.)