Pololu3piPlus32U4 library
|
Interfaces with the inertial sensors on the 3pi+ 32U4. More...
#include <Pololu3piPlus32U4IMU_declaration.h>
Classes | |
struct | vector |
Represents a 3-dimensional vector with x, y, and z components. More... | |
Public Member Functions | |
uint8_t | getLastError () |
Returns 0 if the last I2C communication with the IMU was successful, or a non-zero status code if there was an error. More... | |
bool | init () |
Initializes the inertial sensors and detects their type. More... | |
IMUType | getType () |
Returns the type of the inertial sensors on the 3pi+ 32U4. More... | |
void | enableDefault () |
Enables all of the inertial sensors with a default configuration. More... | |
void | configureForTurnSensing () |
Configures the sensors with settings optimized for turn sensing. More... | |
void | configureForFaceUphill () |
Configures the sensors with settings optimized for the FaceUphill example program. More... | |
void | configureForCompassHeading () |
Configures the sensors with settings optimized for determining a compass heading with the magnetometer. More... | |
void | writeReg (uint8_t addr, uint8_t reg, uint8_t value) |
Writes an 8-bit sensor register. More... | |
uint8_t | readReg (uint8_t addr, uint8_t reg) |
Reads an 8-bit sensor register. More... | |
void | readAcc () |
Takes a reading from the accelerometer and makes the measurements available in a. More... | |
void | readGyro () |
Takes a reading from the gyro and makes the measurements available in g. More... | |
void | readMag () |
Takes a reading from the magnetometer and makes the measurements available in m. More... | |
void | read () |
Takes a reading from all three sensors (accelerometer, gyro, and magnetometer) and makes their measurements available in the respective vectors. More... | |
bool | accDataReady () |
Indicates whether the accelerometer has new measurement data ready. More... | |
bool | gyroDataReady () |
Indicates whether the gyro has new measurement data ready. More... | |
bool | magDataReady () |
Indicates whether the magnetometer has new measurement data ready. More... | |
Public Attributes | |
vector< int16_t > | a = {0, 0, 0} |
Raw accelerometer readings. More... | |
vector< int16_t > | g = {0, 0, 0} |
Raw gyro readings. More... | |
vector< int16_t > | m = {0, 0, 0} |
Raw magnetometer readings. More... | |
Interfaces with the inertial sensors on the 3pi+ 32U4.
This class allows you to configure and get readings from the I2C sensors that make up the 3pi+ 32U4's inertial measurement unit (IMU): gyro, accelerometer, and magnetometer.
The IMU is not fully enabled by default since it depends on the Wire library, which uses about 1400 bytes of additional code space and defines an interrupt service routine (ISR) that might be incompatible with some applications (such as our TWISlave example). To use the IMU, include the file Pololu3piPlus32U4IMU.h in one of your cpp/ino files for IMU functionality (not Pololu3piPlus32U4IMU_declaration.h, where this class is declared).
You must call Wire.start()
before using any of this library's functions that access the sensors.
Definition at line 66 of file Pololu3piPlus32U4IMU_declaration.h.
bool Pololu3piPlus32U4::IMU::accDataReady | ( | ) |
Indicates whether the accelerometer has new measurement data ready.
Definition at line 182 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::configureForCompassHeading | ( | ) |
Configures the sensors with settings optimized for determining a compass heading with the magnetometer.
Definition at line 112 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::configureForFaceUphill | ( | ) |
Configures the sensors with settings optimized for the FaceUphill example program.
Definition at line 95 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::configureForTurnSensing | ( | ) |
Configures the sensors with settings optimized for turn sensing.
Definition at line 78 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::enableDefault | ( | ) |
Enables all of the inertial sensors with a default configuration.
Definition at line 25 of file Pololu3piPlus32U4IMU.cpp.
|
inline |
Returns 0 if the last I2C communication with the IMU was successful, or a non-zero status code if there was an error.
Definition at line 87 of file Pololu3piPlus32U4IMU_declaration.h.
|
inline |
Returns the type of the inertial sensors on the 3pi+ 32U4.
Definition at line 99 of file Pololu3piPlus32U4IMU_declaration.h.
bool Pololu3piPlus32U4::IMU::gyroDataReady | ( | ) |
Indicates whether the gyro has new measurement data ready.
Definition at line 193 of file Pololu3piPlus32U4IMU.cpp.
bool Pololu3piPlus32U4::IMU::init | ( | ) |
Initializes the inertial sensors and detects their type.
Definition at line 11 of file Pololu3piPlus32U4IMU.cpp.
bool Pololu3piPlus32U4::IMU::magDataReady | ( | ) |
Indicates whether the magnetometer has new measurement data ready.
Definition at line 204 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::read | ( | ) |
Takes a reading from all three sensors (accelerometer, gyro, and magnetometer) and makes their measurements available in the respective vectors.
Definition at line 173 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::readAcc | ( | void | ) |
Takes a reading from the accelerometer and makes the measurements available in a.
Definition at line 130 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::readGyro | ( | ) |
Takes a reading from the gyro and makes the measurements available in g.
Definition at line 144 of file Pololu3piPlus32U4IMU.cpp.
void Pololu3piPlus32U4::IMU::readMag | ( | ) |
Takes a reading from the magnetometer and makes the measurements available in m.
Definition at line 158 of file Pololu3piPlus32U4IMU.cpp.
uint8_t Pololu3piPlus32U4::IMU::readReg | ( | uint8_t | addr, |
uint8_t | reg | ||
) |
Reads an 8-bit sensor register.
addr | Device address. |
reg | Register address. |
Definition at line 28 of file Pololu3piPlus32U4IMU.h.
void Pololu3piPlus32U4::IMU::writeReg | ( | uint8_t | addr, |
uint8_t | reg, | ||
uint8_t | value | ||
) |
Writes an 8-bit sensor register.
addr | Device address. |
reg | Register address. |
value | The 8-bit register value to be written. |
Definition at line 20 of file Pololu3piPlus32U4IMU.h.
vector<int16_t> Pololu3piPlus32U4::IMU::a = {0, 0, 0} |
Raw accelerometer readings.
Definition at line 77 of file Pololu3piPlus32U4IMU_declaration.h.
vector<int16_t> Pololu3piPlus32U4::IMU::g = {0, 0, 0} |
Raw gyro readings.
Definition at line 80 of file Pololu3piPlus32U4IMU_declaration.h.
vector<int16_t> Pololu3piPlus32U4::IMU::m = {0, 0, 0} |
Raw magnetometer readings.
Definition at line 83 of file Pololu3piPlus32U4IMU_declaration.h.