AP_AHRS: support MAV_CMD_EXTERNAL_WIND_ESTIMATE

This commit is contained in:
Andrii Fil 2024-09-03 19:12:18 +03:00 committed by Peter Barker
parent 40e367e14f
commit 3344dba627
4 changed files with 18 additions and 0 deletions

View File

@ -131,6 +131,12 @@ public:
#endif
}
#if AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED
void set_external_wind_estimate(float speed, float direction) {
dcm.set_external_wind_estimate(speed, direction);
}
#endif
// return the parameter AHRS_WIND_MAX in metres per second
uint8_t get_max_wind() const {
return _wind_max;

View File

@ -1028,6 +1028,13 @@ void AP_AHRS_DCM::estimate_wind(void)
#endif
}
#ifdef AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED
void AP_AHRS_DCM::set_external_wind_estimate(float speed, float direction) {
_wind.x = -cosf(radians(direction)) * speed;
_wind.y = -sinf(radians(direction)) * speed;
_wind.z = 0;
}
#endif
// return our current position estimate using
// dead-reckoning or GPS

View File

@ -78,6 +78,8 @@ public:
return true;
}
void set_external_wind_estimate(float speed, float direction);
// return an airspeed estimate if available. return true
// if we have an estimate
bool airspeed_estimate(float &airspeed_ret) const override;

View File

@ -41,3 +41,6 @@
#define AP_AHRS_POSITION_RESET_ENABLED (BOARD_FLASH_SIZE>1024 && AP_AHRS_ENABLED)
#endif
#ifndef AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED
#define AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED (BOARD_FLASH_SIZE>1024 && AP_AHRS_DCM_ENABLED)
#endif