From e315c5f28e26f4a7d4f450a1c672b2a3a93c6072 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Jan 2014 17:05:43 +1100 Subject: [PATCH] Rover: enable use of AHRS_NavEKF --- APMrover2/APMrover2.pde | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/APMrover2/APMrover2.pde b/APMrover2/APMrover2.pde index 1e4da0cf44..23b8474f8b 100644 --- a/APMrover2/APMrover2.pde +++ b/APMrover2/APMrover2.pde @@ -70,6 +70,7 @@ #include // ArduPilot Mega Vector/Matrix math Library #include // Inertial Sensor (uncalibated IMU) Library #include // ArduPilot Mega DCM Library +#include #include // PID library #include // RC Channel Library #include // Range finder library @@ -257,7 +258,31 @@ AP_InertialSensor_Oilpan ins( &adc ); #error Unrecognised CONFIG_INS_TYPE setting. #endif // CONFIG_INS_TYPE -AP_AHRS_DCM ahrs(ins, g_gps); + +#if CONFIG_BARO == AP_BARO_BMP085 +static AP_Baro_BMP085 barometer; +#elif CONFIG_BARO == AP_BARO_PX4 +static AP_Baro_PX4 barometer; +#elif CONFIG_BARO == AP_BARO_HIL +static AP_Baro_HIL barometer; +#elif CONFIG_BARO == AP_BARO_MS5611 + #if CONFIG_MS5611_SERIAL == AP_BARO_MS5611_SPI + static AP_Baro_MS5611 barometer(&AP_Baro_MS5611::spi); + #elif CONFIG_MS5611_SERIAL == AP_BARO_MS5611_I2C + static AP_Baro_MS5611 barometer(&AP_Baro_MS5611::i2c); + #else + #error Unrecognized CONFIG_MS5611_SERIAL setting. + #endif +#else + #error Unrecognized CONFIG_BARO setting +#endif + +// Inertial Navigation EKF +#if AP_AHRS_NAVEKF_AVAILABLE +AP_AHRS_NavEKF ahrs(ins, barometer, g_gps); +#else +AP_AHRS_DCM ahrs(ins, barometer, g_gps); +#endif static AP_L1_Control L1_controller(ahrs);