IMU - Inertial Measurement Unit
Description
Inertial Measurement Unit driver.
IMU example code
Basic example for looping measurement of orientation data:
#include "sl_imu.h" int main( void ) { ... int16_t o_vec[3]; sl_imu_init(); // Configure sample rate sl_imu_configure(10); // Recalibrate gyro sl_imu_calibrate_gyro(); while (true) { sl_imu_update(); while (!sl_imu_is_data_ready()) { // wait } sl_imu_get_orientation(o_vec); ... } }
Modules |
|
Direction Cosine Matrix | |
Unit DCM matrix related routines.
|
|
IMU Fusion | |
IMU fusion driver.
|
|
Vector and Matrix Math | |
Inertial measurement unit fusion driver math routines.
|
|
Functions |
|
sl_status_t | sl_imu_init (void) |
Initialize and calibrate the IMU chip.
|
|
sl_status_t | sl_imu_deinit (void) |
De-initialize the IMU chip.
|
|
uint8_t | sl_imu_get_state (void) |
Return IMU state.
|
|
void | sl_imu_update (void) |
Get a new set of data from the accel and gyro sensor and updates the fusion calculation.
|
|
void | sl_imu_reset (void) |
Reset the fusion calculation.
|
|
void | sl_imu_get_acceleration (int16_t avec[3]) |
Retrieve the processed acceleration data.
|
|
void | sl_imu_get_orientation (int16_t ovec[3]) |
Retrieve the processed orientation data.
|
|
void | sl_imu_get_gyro (int16_t gvec[3]) |
Retrieve the processed gyroscope data.
|
|
sl_status_t | sl_imu_calibrate_gyro (void) |
Perform gyroscope calibration to cancel gyro bias.
|
|
void | sl_imu_get_gyro_correction_angles (float acorr[3]) |
Retrieve the processed gyroscope correction angles.
|
|
void | sl_imu_configure (float sampleRate) |
Configure the IMU.
|
|
bool | sl_imu_is_data_ready (void) |
Check if new accel/gyro data is available for read.
|
|
void | sl_imu_get_acceleration_raw_data (float avec[3]) |
Retrieve the raw acceleration data from the IMU.
|
|
void | sl_imu_get_gyro_raw_data (float gvec[3]) |
Retrieve the raw gyroscope data from the IMU.
|
|
State Definitions |
|
#define | IMU_STATE_DISABLED 0x00 |
The IMU is disabled
|
|
#define | IMU_STATE_READY 0x01 |
The IMU is fully configured and ready to take measurements
|
|
#define | IMU_STATE_INITIALIZING 0x02 |
The IMU is being initialized
|
|
#define | IMU_STATE_CALIBRATING 0x03 |
The IMU is being calibrated
|
|
Function Documentation
◆ sl_imu_init()
sl_status_t sl_imu_init | ( | void |
|
) |
Initialize and calibrate the IMU chip.
- Returns
- Returns zero on OK, non-zero otherwise
◆ sl_imu_deinit()
sl_status_t sl_imu_deinit | ( | void |
|
) |
De-initialize the IMU chip.
- Returns
- Returns zero on OK, non-zero otherwise
◆ sl_imu_get_state()
uint8_t sl_imu_get_state | ( | void |
|
) |
Return IMU state.
- Returns
- IMU state
◆ sl_imu_update()
void sl_imu_update | ( | void |
|
) |
Get a new set of data from the accel and gyro sensor and updates the fusion calculation.
◆ sl_imu_reset()
void sl_imu_reset | ( | void |
|
) |
Reset the fusion calculation.
◆ sl_imu_get_acceleration()
void sl_imu_get_acceleration | ( | int16_t |
avec[3]
|
) |
Retrieve the processed acceleration data.
- Parameters
-
[out] avec
Three dimensional acceleration vector
◆ sl_imu_get_orientation()
void sl_imu_get_orientation | ( | int16_t |
ovec[3]
|
) |
Retrieve the processed orientation data.
- Parameters
-
[out] ovec
Three dimensional orientation vector
◆ sl_imu_get_gyro()
void sl_imu_get_gyro | ( | int16_t |
gvec[3]
|
) |
Retrieve the processed gyroscope data.
- Parameters
-
[out] gvec
Three dimensional gyro vector
◆ sl_imu_calibrate_gyro()
sl_status_t sl_imu_calibrate_gyro | ( | void |
|
) |
Perform gyroscope calibration to cancel gyro bias.
- Return values
-
SL_STATUS_OK
◆ sl_imu_get_gyro_correction_angles()
void sl_imu_get_gyro_correction_angles | ( | float |
acorr[3]
|
) |
Retrieve the processed gyroscope correction angles.
- Parameters
-
[out] acorr
Three dimensional gyro correction angle vector
◆ sl_imu_configure()
void sl_imu_configure | ( | float |
sampleRate
|
) |
Configure the IMU.
- Parameters
-
[in] sampleRate
The desired sample rate of the acceleration and gyro sensor
◆ sl_imu_is_data_ready()
bool sl_imu_is_data_ready | ( | void |
|
) |
Check if new accel/gyro data is available for read.
- Returns
- True if the measurement data is ready, false otherwise
◆ sl_imu_get_acceleration_raw_data()
void sl_imu_get_acceleration_raw_data | ( | float |
avec[3]
|
) |
Retrieve the raw acceleration data from the IMU.
- Parameters
-
[out] avec
Three dimensional raw acceleration vector
◆ sl_imu_get_gyro_raw_data()
void sl_imu_get_gyro_raw_data | ( | float |
gvec[3]
|
) |
Retrieve the raw gyroscope data from the IMU.
- Parameters
-
[out] gvec
Three dimensional raw gyro vector
Macro Definition Documentation
◆ IMU_STATE_DISABLED
#define IMU_STATE_DISABLED 0x00 |
The IMU is disabled
◆ IMU_STATE_READY
#define IMU_STATE_READY 0x01 |
The IMU is fully configured and ready to take measurements
◆ IMU_STATE_INITIALIZING
#define IMU_STATE_INITIALIZING 0x02 |
The IMU is being initialized
◆ IMU_STATE_CALIBRATING
#define IMU_STATE_CALIBRATING 0x03 |
The IMU is being calibrated