IMU - Inertial Measurement Unit#
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#
State Definitions#
The IMU is disabled
The IMU is fully configured and ready to take measurements
The IMU is being initialized
The IMU is being calibrated
Functions#
Initialize and calibrate the IMU chip.
De-initialize the IMU chip.
Return IMU state.
Get a new set of data from the accel and gyro sensor and updates the fusion calculation.
Reset the fusion calculation.
Retrieve the processed acceleration data.
Retrieve the processed orientation data.
Retrieve the processed gyroscope data.
Perform gyroscope calibration to cancel gyro bias.
Retrieve the processed gyroscope correction angles.
Configure the IMU.
Check if new accel/gyro data is available for read.
Retrieve the raw acceleration data from the IMU.
Retrieve the raw gyroscope data from the IMU.
State Definitions Documentation#
IMU_STATE_DISABLED#
#define IMU_STATE_DISABLEDValue:
0x00
The IMU is disabled
100
of file hardware/driver/imu/inc/sl_imu.h
IMU_STATE_READY#
#define IMU_STATE_READYValue:
0x01
The IMU is fully configured and ready to take measurements
101
of file hardware/driver/imu/inc/sl_imu.h
IMU_STATE_INITIALIZING#
#define IMU_STATE_INITIALIZINGValue:
0x02
The IMU is being initialized
102
of file hardware/driver/imu/inc/sl_imu.h
IMU_STATE_CALIBRATING#
#define IMU_STATE_CALIBRATINGValue:
0x03
The IMU is being calibrated
103
of file hardware/driver/imu/inc/sl_imu.h
Function Documentation#
sl_imu_init#
sl_status_t sl_imu_init (void )
Initialize and calibrate the IMU chip.
N/A |
Returns
Returns zero on OK, non-zero otherwise
145
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_deinit#
sl_status_t sl_imu_deinit (void )
De-initialize the IMU chip.
N/A |
Returns
Returns zero on OK, non-zero otherwise
154
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_state#
uint8_t sl_imu_get_state (void )
Return IMU state.
N/A |
Returns
IMU state
163
of file hardware/driver/imu/inc/sl_imu.h
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.
N/A |
170
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_reset#
void sl_imu_reset (void )
Reset the fusion calculation.
N/A |
176
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_acceleration#
void sl_imu_get_acceleration (int16_t avec)
Retrieve the processed acceleration data.
[out] | avec | Three dimensional acceleration vector |
185
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_orientation#
void sl_imu_get_orientation (int16_t ovec)
Retrieve the processed orientation data.
[out] | ovec | Three dimensional orientation vector |
194
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_gyro#
void sl_imu_get_gyro (int16_t gvec)
Retrieve the processed gyroscope data.
[out] | gvec | Three dimensional gyro vector |
203
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_calibrate_gyro#
sl_status_t sl_imu_calibrate_gyro (void )
Perform gyroscope calibration to cancel gyro bias.
N/A |
212
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_gyro_correction_angles#
void sl_imu_get_gyro_correction_angles (float acorr)
Retrieve the processed gyroscope correction angles.
[out] | acorr | Three dimensional gyro correction angle vector |
221
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_configure#
void sl_imu_configure (float sampleRate)
Configure the IMU.
[in] | sampleRate | The desired sample rate of the acceleration and gyro sensor |
425
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_is_data_ready#
bool sl_imu_is_data_ready (void )
Check if new accel/gyro data is available for read.
N/A |
Returns
True if the measurement data is ready, false otherwise
434
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_acceleration_raw_data#
void sl_imu_get_acceleration_raw_data (float avec)
Retrieve the raw acceleration data from the IMU.
[out] | avec | Three dimensional raw acceleration vector |
443
of file hardware/driver/imu/inc/sl_imu.h
sl_imu_get_gyro_raw_data#
void sl_imu_get_gyro_raw_data (float gvec)
Retrieve the raw gyroscope data from the IMU.
[out] | gvec | Three dimensional raw gyro vector |
452
of file hardware/driver/imu/inc/sl_imu.h