49 #define IMU_PI 3.14159265358979323
50 #define IMU_DEG_TO_RAD_FACTOR ( (2.0*IMU_PI) / 360.0 )
51 #define IMU_RAD_TO_DEG_FACTOR ( 360.0 / (2.0*IMU_PI) )
52 #define IMU_DEG_TO_RAD(ang) (ang * IMU_DEG_TO_RAD_FACTOR)
53 #define IMU_RAD_TO_DEG(ang) (ang * IMU_RAD_TO_DEG_FACTOR)
55 #define IMU_MAX_ACCEL_FOR_ANGLE 0.9848
57 #define IMU_STATE_DISABLED 0x00
58 #define IMU_STATE_READY 0x01
59 #define IMU_STATE_INITIALIZING 0x02
60 #define IMU_STATE_CALIBRATING 0x03
74 typedef struct _IMU_SensorFusion
82 float aAccumulator[3];
93 float angleCorrection[3];
164 bool accValid,
bool dirValid,
Structure to store the sensor fusion data.
bool IMU_isDataReadyFlag(void)
Checks if there is new accel/gyro data available for read. In case of ver 0.3.0 and older of the PIC ...
void IMU_config(float sampleRate)
Configures the IMU.
void IMU_fuseGyroUpdate(IMU_SensorFusion *f, float gvec[3])
Updates the fusion calculation with a new gyro data.
void IMU_normalizeAngle(float *a)
Normalizes the angle ( -PI < angle <= PI )
void IMU_vectorCrossProduct(float r[3], float a[3], float b[3])
Calculates the cross product of two vectors.
void IMU_vectorNormalizeAngle(float v[3])
Normalizes the angle of a vector.
Power and Interrupt Controller Register Definitions.
struct _IMU_SensorFusion IMU_SensorFusion
Structure to store the sensor fusion data.
void IMU_dcmReset(float dcm[3][3])
Sets the elements of the DCM matrixto the corresponding elements of the identity matrix.
void IMU_fuseGyroCorrection(IMU_SensorFusion *f, bool accValid, bool dirValid, float dirZ)
Calculates the gyro correction vector.
uint8_t IMU_getState(void)
Returns IMU state.
void IMU_vectorScale(float v[3], float scale)
Scales a vector by a factor.
void IMU_dcmNormalize(float dcm[3][3])
Normalizes the DCM matrix.
void IMU_getGyroData(float gvec[3])
Retrieves the raw gyroscope data from the IMU.
void IMU_fuseAccelerometerUpdateFilter(IMU_SensorFusion *f, float avec[3])
The current accelerometer data is added to the accumulator.
void IMU_vectorZero(float v[3])
Sets all elements of a vector to 0.
void IMU_fuseAccelerometerSetSampleRate(IMU_SensorFusion *f, float rate)
Sets the accelerometer sample rate in the IMU_SensorFusion structure.
void IMU_update(void)
Gets a new set of data from the accel and gyro sensor and updates the fusion calculation.
void IMU_matrixMultiply(float c[3][3], float a[3][3], float b[3][3])
Multiplies two 3x3 matrices.
void IMU_dcmRotate(float dcm[3][3], float ang[3])
Rotates the DCM matrix by a given angle.
General Purpose IO (GPIO) peripheral API.
I2C simple poll-based master mode driver for the DK/STK.
void IMU_getAccelerometerData(float avec[3])
Retrieves the raw acceleration data from the IMU.
uint32_t IMU_gyroCalibrate(void)
Performs gyroscope calibration to cancel gyro bias.
void IMU_gyroGet(int16_t gvec[3])
Retrieves the processed gyroscope data.
void IMU_fuseReset(IMU_SensorFusion *f)
Clears the values of the sensor fusion object.
uint32_t IMU_init(void)
Initializes and calibrates the IMU.
void IMU_dcmGetAngles(float dcm[3][3], float ang[3])
Calculates the Euler angles (roll, pitch, yaw) from the DCM matrix.
void IMU_clearDataReadyFlag(void)
Clears the IMU data ready flag. In case of ver 0.3.0 and older of the PIC firmware the interrupt regi...
void IMU_fuseGyroCorrectionClear(IMU_SensorFusion *f)
Clears the gyro correction vector.
void IMU_getGyroCorrectionAngles(float acorr[3])
Retrieves the processed gyroscope correction angles.
void IMU_dcmResetZ(float dcm[3][3])
DCM reset, Z direction.
void IMU_vectorAdd(float r[3], float a[3], float b[3])
Adds two vectors.
void IMU_accelerationGet(int16_t avec[3])
Retrieves the processed acceleration data.
bool IMU_isDataReady(void)
Checks if there is new accel/gyro data available for read.
void IMU_fuseNew(IMU_SensorFusion *f)
Initializes a new IMU_SensorFusion structure.
void IMU_vectorSubtract(float r[3], float a[3], float b[3])
Subtracts vector b from vector a.
float IMU_vectorDotProduct(float a[3], float b[3])
Calculates the dot product of two vectors.
void IMU_fuseUpdate(IMU_SensorFusion *f)
Updates the fusion calculation.
uint32_t aAccumulatorCount
void IMU_fuseGyroSetSampleRate(IMU_SensorFusion *f, float rate)
Sets the gyro sample rate and related values in the IMU_SensorFusion structure.
void IMU_vectorScalarMultiplication(float r[3], float v[3], float scale)
Multiplies a vector by a scalar.
void IMU_reset(void)
Resets the fusion calculation.
void IMU_orientationGet(int16_t ovec[3])
Retrieves the processed orientation data.
uint32_t IMU_deInit(void)
De-initializes the IMU chip.