From 1c92ecc89f2e49a471f460c325dbbcb42745327c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Aug 2019 19:28:37 +1000 Subject: [PATCH] AP_InertialSensor: removed old method of specifying most IMUs and removed dangerous default values for rotations --- .../AP_InertialSensor/AP_InertialSensor.cpp | 41 +------------------ .../AP_InertialSensor_BMI055.h | 4 +- .../AP_InertialSensor_BMI088.h | 4 +- .../AP_InertialSensor_Invensense.h | 4 +- .../AP_InertialSensor_Invensensev2.h | 4 +- 5 files changed, 9 insertions(+), 48 deletions(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.cpp b/libraries/AP_InertialSensor/AP_InertialSensor.cpp index 7a3e7bb067..b8443763f5 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor.cpp @@ -720,23 +720,10 @@ AP_InertialSensor::detect_backends(void) ADD_BACKEND(AP_InertialSensor_SITL::detect(*this)); #elif HAL_INS_DEFAULT == HAL_INS_HIL ADD_BACKEND(AP_InertialSensor_HIL::detect(*this)); -#elif HAL_INS_DEFAULT == HAL_INS_MPU60XX_SPI && defined(HAL_INS_DEFAULT_ROTATION) - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME), - HAL_INS_DEFAULT_ROTATION)); -#elif HAL_INS_DEFAULT == HAL_INS_MPU60XX_SPI - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME))); -#elif HAL_INS_DEFAULT == HAL_INS_MPU60XX_I2C && defined(HAL_INS_DEFAULT_ROTATION) - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.i2c_mgr->get_device(HAL_INS_MPU60x0_I2C_BUS, HAL_INS_MPU60x0_I2C_ADDR), - HAL_INS_DEFAULT_ROTATION)); -#elif HAL_INS_DEFAULT == HAL_INS_MPU60XX_I2C - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.i2c_mgr->get_device(HAL_INS_MPU60x0_I2C_BUS, HAL_INS_MPU60x0_I2C_ADDR))); -#elif HAL_INS_DEFAULT == HAL_INS_BH - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.i2c_mgr->get_device(HAL_INS_MPU60x0_I2C_BUS, HAL_INS_MPU60x0_I2C_ADDR))); - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME))); #elif AP_FEATURE_BOARD_DETECT switch (AP_BoardConfig::get_board_type()) { case AP_BoardConfig::PX4_BOARD_PX4V1: - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME))); + ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME), ROTATION_NONE)); break; case AP_BoardConfig::PX4_BOARD_PIXHAWK: @@ -853,32 +840,6 @@ AP_InertialSensor::detect_backends(void) default: break; } -#elif HAL_INS_DEFAULT == HAL_INS_MPU9250_SPI && defined(HAL_INS_DEFAULT_ROTATION) - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME), HAL_INS_DEFAULT_ROTATION)); -#elif HAL_INS_DEFAULT == HAL_INS_MPU9250_SPI - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME))); -#elif HAL_INS_DEFAULT == HAL_INS_EDGE - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME), ROTATION_YAW_90)); - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME_EXT), ROTATION_YAW_90)); -#elif HAL_INS_DEFAULT == HAL_INS_L3G4200D - ADD_BACKEND(AP_InertialSensor_L3G4200D::probe(*this, hal.i2c_mgr->get_device(HAL_INS_L3G4200D_I2C_BUS, HAL_INS_L3G4200D_I2C_ADDR))); -#elif HAL_INS_DEFAULT == HAL_INS_MPU9250_I2C - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.i2c_mgr->get_device(HAL_INS_MPU9250_I2C_BUS, HAL_INS_MPU9250_I2C_ADDR))); -#elif HAL_INS_DEFAULT == HAL_INS_BBBMINI - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME))); - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME_EXT))); -#elif HAL_INS_DEFAULT == HAL_INS_AERO - ADD_BACKEND(AP_InertialSensor_BMI160::probe(*this, hal.spi->get_device("bmi160"))); -#elif HAL_INS_DEFAULT == HAL_INS_RST - ADD_BACKEND(AP_InertialSensor_RST::probe(*this, hal.spi->get_device(HAL_INS_RST_G_NAME), - hal.spi->get_device(HAL_INS_RST_A_NAME), - HAL_INS_DEFAULT_G_ROTATION, - HAL_INS_DEFAULT_A_ROTATION)); -#elif HAL_INS_DEFAULT == HAL_INS_ICM20789_SPI - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device("icm20789"))); -#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_OMNIBUSF7V2 - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device("mpu6000"), ROTATION_NONE)); - ADD_BACKEND(AP_InertialSensor_Invensense::probe(*this, hal.spi->get_device("mpu6500"), ROTATION_YAW_90)); #elif HAL_INS_DEFAULT == HAL_INS_NONE // no INS device #else diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_BMI055.h b/libraries/AP_InertialSensor/AP_InertialSensor_BMI055.h index 8f7254a1fc..5b5773a327 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_BMI055.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_BMI055.h @@ -28,7 +28,7 @@ public: static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev_accel, AP_HAL::OwnPtr dev_gyro, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /** * Configure the sensors and start reading routine. @@ -40,7 +40,7 @@ private: AP_InertialSensor_BMI055(AP_InertialSensor &imu, AP_HAL::OwnPtr dev_accel, AP_HAL::OwnPtr dev_gyro, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /* initialise hardware layer diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_BMI088.h b/libraries/AP_InertialSensor/AP_InertialSensor_BMI088.h index 3aca89edac..cf1abd775f 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_BMI088.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_BMI088.h @@ -28,7 +28,7 @@ public: static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev_accel, AP_HAL::OwnPtr dev_gyro, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /** * Configure the sensors and start reading routine. @@ -40,7 +40,7 @@ private: AP_InertialSensor_BMI088(AP_InertialSensor &imu, AP_HAL::OwnPtr dev_accel, AP_HAL::OwnPtr dev_gyro, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /* initialise hardware layer diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_Invensense.h b/libraries/AP_InertialSensor/AP_InertialSensor_Invensense.h index a9578134ba..fbc2ef7c23 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_Invensense.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_Invensense.h @@ -39,11 +39,11 @@ public: static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /* update accel and gyro state */ bool update() override; diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_Invensensev2.h b/libraries/AP_InertialSensor/AP_InertialSensor_Invensensev2.h index 55cf57396e..fc3f5ca186 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_Invensensev2.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_Invensensev2.h @@ -35,11 +35,11 @@ public: static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu, AP_HAL::OwnPtr dev, - enum Rotation rotation = ROTATION_NONE); + enum Rotation rotation); /* update accel and gyro state */ bool update() override;