Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu.h File Reference

Inertial Measurement Unit interface. More...

#include "math/pprz_algebra_int.h"
#include "math/pprz_algebra_float.h"
#include "math/pprz_orientation_conversion.h"
#include "generated/airframe.h"
+ Include dependency graph for imu.h:

Go to the source code of this file.

Data Structures

struct  Imu
 abstract IMU interface providing fixed point interface More...
 
struct  ImuFloat
 abstract IMU interface providing floating point interface More...
 

Macros

#define IMU_BODY_TO_IMU_PHI   0
 
#define IMU_BODY_TO_IMU_THETA   0
 
#define IMU_BODY_TO_IMU_PSI   0
 
#define IMU_GYRO_P_NEUTRAL   0
 
#define IMU_GYRO_Q_NEUTRAL   0
 
#define IMU_GYRO_R_NEUTRAL   0
 
#define IMU_ACCEL_X_NEUTRAL   0
 
#define IMU_ACCEL_Y_NEUTRAL   0
 
#define IMU_ACCEL_Z_NEUTRAL   0
 
#define ImuScaleGyro(_imu)
 
#define ImuScaleAccel(_imu)
 
#define ImuScaleMag(_imu)
 

Functions

void imu_impl_init (void)
 Navstik IMU initializtion of the MPU-60x0 and HMC58xx. More...
 
void imu_periodic (void)
 Handle all the periodic tasks of the Navstik IMU components. More...
 
void imu_init (void)
 
void imu_float_init (void)
 
void imu_SetBodyToImuPhi (float phi)
 
void imu_SetBodyToImuTheta (float theta)
 
void imu_SetBodyToImuPsi (float psi)
 
void imu_SetBodyToImuCurrent (float set)
 
void imu_ResetBodyToImu (float reset)
 

Variables

struct Imu imu
 global IMU state More...
 
struct ImuFloat imuf
 

Detailed Description

Inertial Measurement Unit interface.

Definition in file imu.h.

Macro Definition Documentation

#define IMU_ACCEL_X_NEUTRAL   0

Definition at line 102 of file imu.h.

#define IMU_ACCEL_Y_NEUTRAL   0

Definition at line 103 of file imu.h.

#define IMU_ACCEL_Z_NEUTRAL   0

Definition at line 104 of file imu.h.

#define IMU_BODY_TO_IMU_PHI   0

Definition at line 90 of file imu.h.

Referenced by imu_float_init(), imu_init(), and imu_SetBodyToImuCurrent().

#define IMU_BODY_TO_IMU_PSI   0

Definition at line 92 of file imu.h.

Referenced by imu_float_init(), imu_init(), and imu_SetBodyToImuCurrent().

#define IMU_BODY_TO_IMU_THETA   0

Definition at line 91 of file imu.h.

Referenced by imu_float_init(), imu_init(), and imu_SetBodyToImuCurrent().

#define IMU_GYRO_P_NEUTRAL   0

Definition at line 96 of file imu.h.

#define IMU_GYRO_Q_NEUTRAL   0

Definition at line 97 of file imu.h.

#define IMU_GYRO_R_NEUTRAL   0

Definition at line 98 of file imu.h.

#define ImuScaleAccel (   _imu)
Value:
{ \
VECT3_COPY(_imu.accel_prev, _imu.accel); \
_imu.accel.x = ((_imu.accel_unscaled.x - _imu.accel_neutral.x)*IMU_ACCEL_X_SIGN*IMU_ACCEL_X_SENS_NUM)/IMU_ACCEL_X_SENS_DEN; \
_imu.accel.y = ((_imu.accel_unscaled.y - _imu.accel_neutral.y)*IMU_ACCEL_Y_SIGN*IMU_ACCEL_Y_SENS_NUM)/IMU_ACCEL_Y_SENS_DEN; \
_imu.accel.z = ((_imu.accel_unscaled.z - _imu.accel_neutral.z)*IMU_ACCEL_Z_SIGN*IMU_ACCEL_Z_SENS_NUM)/IMU_ACCEL_Z_SENS_DEN; \
}
#define IMU_ACCEL_X_SIGN
Definition: imu_apogee.h:46
#define IMU_ACCEL_Z_SIGN
Definition: imu_apogee.h:48
#define IMU_ACCEL_Y_SENS_DEN
Definition: imu_apogee.h:86
#define IMU_ACCEL_Y_SIGN
Definition: imu_apogee.h:47
#define IMU_ACCEL_Z_SENS_DEN
Definition: imu_apogee.h:89
#define IMU_ACCEL_X_SENS_DEN
Definition: imu_apogee.h:83
#define VECT3_COPY(_a, _b)
Definition: pprz_algebra.h:129
#define IMU_ACCEL_Y_SENS_NUM
Definition: imu_apogee.h:85
#define IMU_ACCEL_Z_SENS_NUM
Definition: imu_apogee.h:88
#define IMU_ACCEL_X_SENS_NUM
Definition: imu_apogee.h:82

Definition at line 119 of file imu.h.

#define ImuScaleGyro (   _imu)
Value:
{ \
RATES_COPY(_imu.gyro_prev, _imu.gyro); \
_imu.gyro.p = ((_imu.gyro_unscaled.p - _imu.gyro_neutral.p)*IMU_GYRO_P_SIGN*IMU_GYRO_P_SENS_NUM)/IMU_GYRO_P_SENS_DEN; \
_imu.gyro.q = ((_imu.gyro_unscaled.q - _imu.gyro_neutral.q)*IMU_GYRO_Q_SIGN*IMU_GYRO_Q_SENS_NUM)/IMU_GYRO_Q_SENS_DEN; \
_imu.gyro.r = ((_imu.gyro_unscaled.r - _imu.gyro_neutral.r)*IMU_GYRO_R_SIGN*IMU_GYRO_R_SENS_NUM)/IMU_GYRO_R_SENS_DEN; \
}
#define IMU_GYRO_Q_SENS_DEN
Definition: imu_apogee.h:63
#define IMU_GYRO_P_SIGN
Definition: imu_apogee.h:41
#define RATES_COPY(_a, _b)
Definition: pprz_algebra.h:326
#define IMU_GYRO_Q_SENS_NUM
Definition: imu_apogee.h:62
#define IMU_GYRO_P_SENS_NUM
Definition: imu_apogee.h:59
#define IMU_GYRO_R_SENS_NUM
Definition: imu_apogee.h:65
#define IMU_GYRO_P_SENS_DEN
Definition: imu_apogee.h:60
#define IMU_GYRO_R_SIGN
Definition: imu_apogee.h:43
#define IMU_GYRO_R_SENS_DEN
Definition: imu_apogee.h:66
#define IMU_GYRO_Q_SIGN
Definition: imu_apogee.h:42

Definition at line 109 of file imu.h.

#define ImuScaleMag (   _imu)
Value:
{ \
_imu.mag.x = ((_imu.mag_unscaled.x - _imu.mag_neutral.x) * IMU_MAG_X_SIGN * IMU_MAG_X_SENS_NUM) / IMU_MAG_X_SENS_DEN; \
_imu.mag.y = ((_imu.mag_unscaled.y - _imu.mag_neutral.y) * IMU_MAG_Y_SIGN * IMU_MAG_Y_SENS_NUM) / IMU_MAG_Y_SENS_DEN; \
_imu.mag.z = ((_imu.mag_unscaled.z - _imu.mag_neutral.z) * IMU_MAG_Z_SIGN * IMU_MAG_Z_SENS_NUM) / IMU_MAG_Z_SENS_DEN; \
}
#define IMU_MAG_Y_SENS_NUM
#define IMU_MAG_X_SENS_DEN
#define IMU_MAG_X_SIGN
Definition: imu_hbmini.h:57
#define IMU_MAG_Z_SIGN
Definition: imu_hbmini.h:59
#define IMU_MAG_Z_SENS_NUM
#define IMU_MAG_Y_SENS_DEN
#define IMU_MAG_Y_SIGN
Definition: imu_hbmini.h:58
#define IMU_MAG_X_SENS_NUM
#define IMU_MAG_Z_SENS_DEN

Definition at line 147 of file imu.h.

Function Documentation

void imu_float_init ( void  )

Definition at line 158 of file imu.c.

References ImuFloat::body_to_imu, IMU_BODY_TO_IMU_PHI, IMU_BODY_TO_IMU_PSI, IMU_BODY_TO_IMU_THETA, imuf, and orientationSetEulers_f().

Referenced by init_ap(), and main_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void imu_impl_init ( void  )

Navstik IMU initializtion of the MPU-60x0 and HMC58xx.

Todo:
drdy int handling for adxl345
Todo:
eoc interrupt for itg3200, polling for now (including status reg)
Todo:
drdy int handling for adxl345
Todo:
eoc interrupt for itg3200, polling for now (including status reg)
Todo:
drdy int handling for adxl345

Definition at line 68 of file imu_apogee.c.

References ImuAspirin::acc_adxl, ImuAspirinI2c::acc_adxl, ImuGL1I2c::acc_adxl, ImuPpzuav::acc_adxl, ImuNavgo::acc_valid, ImuHbmini::acc_valid, ImuApogee::acc_valid, ImuKrooz::acc_valid, ImuUmarim::acc_valid, ImuXsens::accel_available, ImuNps::accel_available, Mpu60x0Config::accel_range, ImuKrooz::accel_sum, ImuAspirin::accel_valid, ImuAspirinI2c::accel_valid, ImuGL1I2c::accel_valid, ImuAspirin2Spi::accel_valid, ImuPx4fmu::accel_valid, ImuMpu6000Hmc5883::accel_valid, ImuPpzuav::accel_valid, ImuNavstik::accel_valid, ImuDrotek2::accel_valid, ImuKrooz::ad7689_spi_rx_buffer, ImuKrooz::ad7689_spi_tx_buffer, ImuKrooz::ad7689_trans, adc_buf_channel(), ADS8344_available, ImuNavgo::adxl, ImuUmarim::adxl, ADXL345_ADDR, ADXL345_ADDR_ALT, adxl345_i2c_init(), adxl345_spi_init(), spi_transaction::after_cb, ahrs, ahrs_align(), ahrs_impl, AHRS_RUNNING, ami601_init(), analog_imu_adc_buf, analog_imu_available, APOGEE_ACCEL_RANGE, APOGEE_GYRO_RANGE, APOGEE_LOWPASS_FILTER, APOGEE_SMPLRT_DIV, aspirin2_mpu60x0, ASPIRIN_2_ACCEL_RANGE, ASPIRIN_2_GYRO_RANGE, ASPIRIN_2_SPI_DEV, ASPIRIN_2_SPI_SLAVE_IDX, ASPIRIN_ACCEL_RATE, ASPIRIN_GYRO_LOWPASS, ASPIRIN_GYRO_SMPLRT_DIV, ASPIRIN_I2C_DEV, ASPIRIN_SPI_DEV, ASPIRIN_SPI_SLAVE_IDX, spi_transaction::before_cb, spi_transaction::bitorder, i2c_transaction::buf, buf_out, spi_transaction::cdiv, GX3Packet::chksm_error, UM6Packet::chksm_error, Adxl345_I2c::config, Adxl345_Spi::config, Mpu60x0_Spi::config, Mpu60x0_I2c::config, L3g4200::config, Itg3200::config, Mpu60x0I2cSlave::configure, configure_baro_slave(), spi_transaction::cpha, spi_transaction::cpol, L3g4200Config::ctrl_reg1, L3g4200Config::ctrl_reg4, L3g4200Config::ctrl_reg5, data_chk, Itg3200Config::dlpf_cfg, Mpu60x0Config::dlpf_cfg, Mpu60x0Config::drdy_int_enable, DROTEK_2_ACCEL_RANGE, DROTEK_2_GYRO_RANGE, DROTEK_2_HMC_I2C_ADDR, DROTEK_2_MPU_I2C_ADDR, spi_transaction::dss, FALSE, GL1_ACCEL_RATE, GL1_GYRO_LOWPASS, GL1_GYRO_SMPLRT, gpio_set(), gpio_setup_output(), AhrsFloatQuat::gx3_packet, AhrsFloatQuat::gx3_status, GX3PacketWaiting, GX3Uninit, ImuNavgo::gyr_valid, ImuHbmini::gyr_valid, ImuApogee::gyr_valid, ImuKrooz::gyr_valid, ImuUmarim::gyr_valid, ImuXsens::gyro_available, ImuNps::gyro_available, ImuAspirin::gyro_itg, ImuAspirinI2c::gyro_itg, ImuPpzuav::gyro_itg, ImuGL1I2c::gyro_l3g, Mpu60x0Config::gyro_range, ImuAspirin::gyro_valid, ImuAspirinI2c::gyro_valid, ImuGL1I2c::gyro_valid, ImuAspirin2Spi::gyro_valid, ImuPx4fmu::gyro_valid, ImuMpu6000Hmc5883::gyro_valid, ImuPpzuav::gyro_valid, ImuNavstik::gyro_valid, ImuDrotek2::gyro_valid, GX3Packet::hdr_error, UM6Packet::hdr_error, ImuPx4fmu::hmc, ImuMpu6000Hmc5883::hmc, ImuNavgo::hmc, ImuHbmini::hmc, ImuNavstik::hmc, ImuDrotek2::hmc, ImuKrooz::hmc, hmc5843_init(), HMC58XX_ADDR, hmc58xx_init(), ImuKrooz::hmc_eoc, HMC_TYPE_5843, HMC_TYPE_5883, Mpu60x0Config::i2c_bypass, Mpu60x0Config::i2c_mst_clk, Mpu60x0Config::i2c_mst_delay, i2c_transmit(), I2CTransPending, imu_apogee, imu_aspirin2, imu_aspirin2_configure_mag_slave(), imu_aspirin_arch_init(), imu_b2, imu_crista_arch_init(), imu_drotek2_configure_mag_slave(), IMU_GX3_LONG_DELAY, imu_hbmini, imu_krooz_sd_arch_init(), IMU_MPU_ACCEL_RANGE, IMU_MPU_GYRO_RANGE, imu_navgo, imu_nps, imu_overrun, IMU_PPZUAV_ACCEL_RATE, IMU_PPZUAV_GYRO_LOWPASS, IMU_PPZUAV_GYRO_SMPLRT_DIV, IMU_PPZUAV_I2C_DEV, IMU_UM6_COMMUNICATION_REG, IMU_UM6_MISC_CONFIG_REG, imu_xsens, InitMedianFilterRatesInt, InitMedianFilterVect3Int, spi_transaction::input_buf, spi_transaction::input_length, ImuNavgo::itg, ImuUmarim::itg, ITG3200_ADDR, ITG3200_ADDR_ALT, itg3200_init(), KROOZ_ACCEL_RANGE, KROOZ_GYRO_RANGE, KROOZ_LOWPASS_FILTER, KROOZ_SMPLRT_DIV, L3G4200_ADDR_ALT, l3g4200_init(), L3G4200_SCALE, ImuXsens::mag_available, ImuNps::mag_available, ImuAspirin::mag_hmc, ImuGL1I2c::mag_hmc, ImuAspirinI2c::mag_hmc, ImuPpzuav::mag_hmc, ImuAspirin::mag_valid, ImuAspirinI2c::mag_valid, ImuGL1I2c::mag_valid, ImuAspirin2Spi::mag_valid, ImuPx4fmu::mag_valid, ImuMpu6000Hmc5883::mag_valid, ImuNavgo::mag_valid, ImuHbmini::mag_valid, ImuPpzuav::mag_valid, ImuNavstik::mag_valid, ImuDrotek2::mag_valid, ImuKrooz::mag_valid, max1168_init(), ImuKrooz::meas_nb, median_mag, ImuAspirin2Spi::mpu, ImuPx4fmu::mpu, ImuMpu6000Hmc5883::mpu, ImuApogee::mpu, ImuNavstik::mpu, ImuDrotek2::mpu, ImuKrooz::mpu, MPU60X0_ADDR, MPU60X0_ADDR_ALT, mpu60x0_i2c_init(), MPU60X0_MST_CLK_400KHZ, MPU60X0_REG_ACCEL_CONFIG, MPU60X0_REG_CONFIG, MPU60X0_REG_GYRO_CONFIG, MPU60X0_REG_PWR_MGMT_1, MPU60X0_REG_SMPLRT_DIV, mpu60x0_spi_init(), ImuKrooz::mpu_eoc, mpu_wait_slave4_ready_cb(), ms2100, ms2100_init(), GX3Packet::msg_available, UM6Packet::msg_available, GX3Packet::msg_idx, UM6Packet::msg_idx, navdata_init(), NAVGO_ACCEL_RATE, NAVGO_GYRO_LOWPASS, NAVGO_GYRO_SMPLRT_DIV, NAVSTIK_ACCEL_RANGE, NAVSTIK_GYRO_RANGE, NAVSTIK_MAG_I2C_DEV, NAVSTIK_MPU_I2C_DEV, Mpu60x0Config::nb_bytes, Mpu60x0Config::nb_slaves, spi_transaction::output_buf, spi_transaction::output_length, PX4FMU_ACCEL_RANGE, PX4FMU_GYRO_RANGE, Adxl345Config::range, Adxl345Config::rate, RATES_ASSIGN, ImuKrooz::rates_sum, register_periodic_telemetry(), spi_transaction::select, ImuAspirin2Spi::slave4_ready, spi_transaction::slave_idx, Mpu60x0Config::slaves, Itg3200Config::smplrt_div, Mpu60x0Config::smplrt_div, spi1, SPI_SLAVE2, SPICphaEdge1, SPICphaEdge2, SPICpolIdleHigh, SPICpolIdleLow, SPIDiv16, SPIDiv64, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, Ahrs::status, GX3Packet::status, UM6Packet::status, i2c_transaction::status, spi_transaction::status, TRUE, Hmc58xx::type, uart_transmit(), UM6_calculate_checksum(), UM6_imu_align(), UM6_packet, UM6_send_packet(), UM6_status, UM6PacketWaiting, UM6Uninit, UMARIM_ACCEL_RANGE, UMARIM_ACCEL_RATE, UMARIM_GYRO_LOWPASS, UMARIM_GYRO_SMPLRT_DIV, VECT3_ASSIGN, ImuAspirin2Spi::wait_slave4_rx_buf, ImuAspirin2Spi::wait_slave4_trans, ImuAspirin2Spi::wait_slave4_tx_buf, and xsens_init().

Referenced by imu_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void imu_periodic ( void  )

Handle all the periodic tasks of the Navstik IMU components.

Read the MPU60x0 every periodic call and the HMC58XX every 10th call.

Definition at line 87 of file imu_apogee.c.

References ImuAspirin::acc_adxl, ImuAspirinI2c::acc_adxl, ImuGL1I2c::acc_adxl, ImuPpzuav::acc_adxl, ImuKrooz::acc_valid, ImuKrooz::accel_filtered, ImuKrooz::accel_sum, Imu::accel_unscaled, ImuNavgo::adxl, ImuUmarim::adxl, adxl345_i2c_periodic(), adxl345_spi_periodic(), ami601_read(), analog_imu_adc_buf, analog_imu_available, aspirin2_mpu60x0, i2c_transaction::buf, Mpu60x0_I2c::config, ImuKrooz::gyr_valid, ImuAspirin::gyro_itg, ImuAspirinI2c::gyro_itg, ImuPpzuav::gyro_itg, ImuGL1I2c::gyro_l3g, Imu::gyro_unscaled, adc_buf::head, ImuPx4fmu::hmc, ImuMpu6000Hmc5883::hmc, ImuNavgo::hmc, ImuHbmini::hmc, ImuNavstik::hmc, ImuDrotek2::hmc, ImuKrooz::hmc, hmc5843_periodic(), hmc58xx_periodic(), hmc58xx_read(), hmc58xx_start_configure(), i2c_transceive(), imu, imu_apogee, imu_aspirin, imu_aspirin2, imu_b2, imu_drotek2, imu_gl1, imu_hbmini, IMU_KROOZ_ACCEL_AVG_FILTER, imu_mpu_hmc, imu_navgo, imu_navstik, imu_overrun, imu_ppzuav, imu_px4fmu, imu_umarim, ImuCristaArchPeriodic, Hmc58xx::initialized, Mpu60x0Config::initialized, INT_VECT3_ZERO, ImuNavgo::itg, ImuUmarim::itg, itg3200_periodic(), l3g4200_periodic(), ImuAspirin::mag_hmc, ImuGL1I2c::mag_hmc, ImuAspirinI2c::mag_hmc, ImuPpzuav::mag_hmc, Max1168Periodic, ImuKrooz::meas_nb, ImuKrooz::meas_nb_acc, ImuAspirin2Spi::mpu, ImuPx4fmu::mpu, ImuMpu6000Hmc5883::mpu, ImuApogee::mpu, ImuNavstik::mpu, ImuDrotek2::mpu, ImuKrooz::mpu, MPU60X0_ADDR, mpu60x0_i2c_periodic(), mpu60x0_i2c_start_configure(), MPU60X0_REG_INT_STATUS, mpu60x0_spi_periodic(), ms2100, ms2100_periodic(), NAVGO_ACCEL_RATE, Int32Rates::p, PERIODIC_FREQUENCY, Int32Rates::q, Int32Rates::r, RATES_ASSIGN, ImuKrooz::rates_sum, adc_buf::sum, TRUE, UpdateMedianFilterVect3Int, VECT3_ADD, VECT3_ASSIGN, VECT3_COPY, VECT3_SDIV, VECT3_SMUL, Uint8Vect3::x, Int32Vect3::x, xsens_periodic(), Uint8Vect3::y, Int32Vect3::y, Uint8Vect3::z, and Int32Vect3::z.

Referenced by main_periodic(), and sensors_task().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void imu_ResetBodyToImu ( float  reset)
void imu_SetBodyToImuPhi ( float  phi)

Definition at line 164 of file imu.c.

References Imu::body_to_imu, imu, orientationGetEulers_f(), orientationSetEulers_f(), and FloatEulers::phi.

+ Here is the call graph for this function:

void imu_SetBodyToImuPsi ( float  psi)

Definition at line 178 of file imu.c.

References Imu::body_to_imu, imu, orientationGetEulers_f(), orientationSetEulers_f(), and FloatEulers::psi.

+ Here is the call graph for this function:

void imu_SetBodyToImuTheta ( float  theta)

Definition at line 171 of file imu.c.

References Imu::body_to_imu, imu, orientationGetEulers_f(), orientationSetEulers_f(), and FloatEulers::theta.

+ Here is the call graph for this function:

Variable Documentation

struct Imu imu
struct ImuFloat imuf

Definition at line 111 of file imu.c.

Referenced by ahrs_init(), gx3_packet_read_message(), and imu_float_init().