float airspeed = _last_airspeed;
#if AP_AIRSPEED_ENABLED
if (airspeed_sensor_enabled()) {
airspeed = AP::airspeed()->get_airspeed();
}
#endif
// use airspeed to estimate our ground velocity in
// earth frame by subtracting the wind
velocity = _dcm_matrix.colx() * airspeed;
// add in wind estimate
velocity += _wind;
we can see that AP::airspeed()->get_airspeed() is treated as TAS, because it is added with wind directly.
So the above code snippet can be rewritten as:
float airspeed = _last_airspeed;
#if AP_AIRSPEED_ENABLED
if (airspeed_sensor_enabled()) {
airspeed = AP::airspeed()->get_airspeed();
}
#endif
// use airspeed to estimate our ground velocity in
// earth frame by subtracting the wind
velocity = _dcm_matrix.colx() * airspeed * get_EAS2TAS();
// add in wind estimate
velocity += _wind;
So, the question is AP::airspeed()->get_airspeed() means TAS or EAS on earth?
because this var is used at the end of this function:
// don't update the drift term if we lost the yaw reference
// for more than 2 seconds
if (yaw_deltat < 2.0f && spin_rate < ToRad(SPIN_RATE_LIMIT)) {
// also add to the I term
_omega_I_sum.z += error_z * _ki_yaw * yaw_deltat;
}
There is two bug in this function:
(1) first bug: from here https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_AHRS/AP_AHRS_DCM.cpp#L1024
we can see that
AP::airspeed()->get_airspeed()
means EAS NOT TAS, becauseTAS = EAS * get_EAS2TAS()
. but, at here https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_AHRS/AP_AHRS_DCM.cpp#L710we can see that
AP::airspeed()->get_airspeed()
is treated as TAS, because it is added with wind directly. So the above code snippet can be rewritten as:So, the question is AP::airspeed()->get_airspeed() means TAS or EAS on earth?
=========================================================== (2) second bug: from here https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_AHRS/AP_AHRS_DCM.cpp#L489
should be fixed as:
because this var is used at the end of this function:
so
yaw_deltat
must be initialized as 0.0f.