mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-10 06:59:54 +08:00
[imu] scaling based on range for MPU9250 IMUs
This commit is contained in:
@@ -61,14 +61,7 @@ PRINT_CONFIG_VAR(IMU_MPU9250_SMPLRT_DIV)
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_GYRO_LOWPASS_FILTER)
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_ACCEL_LOWPASS_FILTER)
|
||||
|
||||
#ifndef IMU_MPU9250_GYRO_RANGE
|
||||
#define IMU_MPU9250_GYRO_RANGE MPU9250_GYRO_RANGE_1000
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_GYRO_RANGE)
|
||||
|
||||
#ifndef IMU_MPU9250_ACCEL_RANGE
|
||||
#define IMU_MPU9250_ACCEL_RANGE MPU9250_ACCEL_RANGE_8G
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_ACCEL_RANGE)
|
||||
|
||||
#ifndef IMU_MPU9250_I2C_ADDR
|
||||
|
||||
@@ -35,39 +35,38 @@
|
||||
#include "peripherals/mpu9250_i2c.h"
|
||||
|
||||
|
||||
/** default gyro sensitivy and neutral from the datasheet
|
||||
* MPU with 1000 deg/s has 32.8 LSB/(deg/s)
|
||||
* sens = 1/32.8 * pi/180 * 2^INT32_RATE_FRAC
|
||||
* sens = 1/32.8 * pi/180 * 4096 = 2.17953
|
||||
I*/
|
||||
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
|
||||
// FIXME
|
||||
#define IMU_GYRO_P_SENS 2.17953
|
||||
#define IMU_GYRO_P_SENS_NUM 18271
|
||||
#define IMU_GYRO_P_SENS_DEN 8383
|
||||
#define IMU_GYRO_Q_SENS 2.17953
|
||||
#define IMU_GYRO_Q_SENS_NUM 18271
|
||||
#define IMU_GYRO_Q_SENS_DEN 8383
|
||||
#define IMU_GYRO_R_SENS 2.17953
|
||||
#define IMU_GYRO_R_SENS_NUM 18271
|
||||
#define IMU_GYRO_R_SENS_DEN 8383
|
||||
#ifndef IMU_MPU9250_GYRO_RANGE
|
||||
#define IMU_MPU9250_GYRO_RANGE MPU9250_GYRO_RANGE_1000
|
||||
#endif
|
||||
|
||||
/** default accel sensitivy from the datasheet
|
||||
* MPU with 8g has 4096 LSB/g
|
||||
* sens = 9.81 [m/s^2] / 4096 [LSB/g] * 2^INT32_ACCEL_FRAC = 2.4525
|
||||
*/
|
||||
#ifndef IMU_MPU9250_ACCEL_RANGE
|
||||
#define IMU_MPU9250_ACCEL_RANGE MPU9250_ACCEL_RANGE_8G
|
||||
#endif
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
|
||||
#define IMU_GYRO_P_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_P_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_P_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#define IMU_GYRO_Q_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_Q_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_Q_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#define IMU_GYRO_R_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_R_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_R_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#endif
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
|
||||
// FIXME
|
||||
#define IMU_ACCEL_X_SENS 2.4525
|
||||
#define IMU_ACCEL_X_SENS_NUM 981
|
||||
#define IMU_ACCEL_X_SENS_DEN 400
|
||||
#define IMU_ACCEL_Y_SENS 2.4525
|
||||
#define IMU_ACCEL_Y_SENS_NUM 981
|
||||
#define IMU_ACCEL_Y_SENS_DEN 400
|
||||
#define IMU_ACCEL_Z_SENS 2.4525
|
||||
#define IMU_ACCEL_Z_SENS_NUM 981
|
||||
#define IMU_ACCEL_Z_SENS_DEN 400
|
||||
#define IMU_ACCEL_X_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_X_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_X_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#define IMU_ACCEL_Y_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_Y_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_Y_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#define IMU_ACCEL_Z_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_Z_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_Z_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -67,14 +67,7 @@ PRINT_CONFIG_VAR(IMU_MPU9250_SMPLRT_DIV)
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_GYRO_LOWPASS_FILTER)
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_ACCEL_LOWPASS_FILTER)
|
||||
|
||||
#ifndef IMU_MPU9250_GYRO_RANGE
|
||||
#define IMU_MPU9250_GYRO_RANGE MPU9250_GYRO_RANGE_1000
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_GYRO_RANGE)
|
||||
|
||||
#ifndef IMU_MPU9250_ACCEL_RANGE
|
||||
#define IMU_MPU9250_ACCEL_RANGE MPU9250_ACCEL_RANGE_8G
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(IMU_MPU9250_ACCEL_RANGE)
|
||||
|
||||
// Default channels order
|
||||
|
||||
@@ -35,39 +35,38 @@
|
||||
#include "peripherals/mpu9250_spi.h"
|
||||
|
||||
|
||||
/** default gyro sensitivy and neutral from the datasheet
|
||||
* MPU with 1000 deg/s has 32.8 LSB/(deg/s)
|
||||
* sens = 1/32.8 * pi/180 * 2^INT32_RATE_FRAC
|
||||
* sens = 1/32.8 * pi/180 * 4096 = 2.17953
|
||||
I*/
|
||||
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
|
||||
// FIXME
|
||||
#define IMU_GYRO_P_SENS 2.17953
|
||||
#define IMU_GYRO_P_SENS_NUM 18271
|
||||
#define IMU_GYRO_P_SENS_DEN 8383
|
||||
#define IMU_GYRO_Q_SENS 2.17953
|
||||
#define IMU_GYRO_Q_SENS_NUM 18271
|
||||
#define IMU_GYRO_Q_SENS_DEN 8383
|
||||
#define IMU_GYRO_R_SENS 2.17953
|
||||
#define IMU_GYRO_R_SENS_NUM 18271
|
||||
#define IMU_GYRO_R_SENS_DEN 8383
|
||||
#ifndef IMU_MPU9250_GYRO_RANGE
|
||||
#define IMU_MPU9250_GYRO_RANGE MPU9250_GYRO_RANGE_1000
|
||||
#endif
|
||||
|
||||
/** default accel sensitivy from the datasheet
|
||||
* MPU with 8g has 4096 LSB/g
|
||||
* sens = 9.81 [m/s^2] / 4096 [LSB/g] * 2^INT32_ACCEL_FRAC = 2.4525
|
||||
*/
|
||||
#ifndef IMU_MPU9250_ACCEL_RANGE
|
||||
#define IMU_MPU9250_ACCEL_RANGE MPU9250_ACCEL_RANGE_8G
|
||||
#endif
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
|
||||
#define IMU_GYRO_P_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_P_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_P_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#define IMU_GYRO_Q_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_Q_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_Q_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#define IMU_GYRO_R_SENS MPU9250_GYRO_SENS[IMU_MPU9250_GYRO_RANGE]
|
||||
#define IMU_GYRO_R_SENS_NUM MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][0]
|
||||
#define IMU_GYRO_R_SENS_DEN MPU9250_GYRO_SENS_FRAC[IMU_MPU9250_GYRO_RANGE][1]
|
||||
#endif
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
|
||||
// FIXME
|
||||
#define IMU_ACCEL_X_SENS 2.4525
|
||||
#define IMU_ACCEL_X_SENS_NUM 981
|
||||
#define IMU_ACCEL_X_SENS_DEN 400
|
||||
#define IMU_ACCEL_Y_SENS 2.4525
|
||||
#define IMU_ACCEL_Y_SENS_NUM 981
|
||||
#define IMU_ACCEL_Y_SENS_DEN 400
|
||||
#define IMU_ACCEL_Z_SENS 2.4525
|
||||
#define IMU_ACCEL_Z_SENS_NUM 981
|
||||
#define IMU_ACCEL_Z_SENS_DEN 400
|
||||
#define IMU_ACCEL_X_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_X_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_X_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#define IMU_ACCEL_Y_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_Y_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_Y_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#define IMU_ACCEL_Z_SENS MPU9250_ACCEL_SENS[IMU_MPU9250_ACCEL_RANGE]
|
||||
#define IMU_ACCEL_Z_SENS_NUM MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][0]
|
||||
#define IMU_ACCEL_Z_SENS_DEN MPU9250_ACCEL_SENS_FRAC[IMU_MPU9250_ACCEL_RANGE][1]
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user