update airspeed usage to airspeed_validated (#13710)

* Mavlink: subscribe to airspeed_validated instead of airspeed topic

	This e.g. changes the way QGC displays the airspeed in case of an
	airspeed failure (0 instead of the last valid airspeed). It will
	always display the airspeed that's used currently in the control
	modules.

* FW land detector: move to subscribe to airspeed_validated instead of airspeed topic
	- the land detector checks further if the airspeed is NAN, in which case
	it sets the airspeed to 0 (min groundspeed, vz  and accel checks still
	have to pass.

* Fixed-wing land detector use airspeed_vaidated: addressed review comments
	- replaced ternary by conditional
	- set airspeed to 0 if airspeed_validated stops publishing

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2019-12-28 18:32:41 +01:00
committed by Daniel Agar
parent fc1341208f
commit 7bb952baed
3 changed files with 18 additions and 12 deletions
@@ -54,7 +54,7 @@ FixedwingLandDetector::FixedwingLandDetector()
void FixedwingLandDetector::_update_topics()
{
LandDetector::_update_topics();
_airspeed_sub.update(&_airspeed);
_airspeed_validated_sub.update(&_airspeed_validated);
}
bool FixedwingLandDetector::_get_landed_state()
@@ -83,7 +83,13 @@ bool FixedwingLandDetector::_get_landed_state()
_velocity_z_filtered = val;
}
_airspeed_filtered = 0.95f * _airspeed_filtered + 0.05f * _airspeed.true_airspeed_m_s;
// set _airspeed_filtered to 0 if airspeed data is invalid
if (!PX4_ISFINITE(_airspeed_validated.true_airspeed_m_s) || hrt_elapsed_time(&_airspeed_validated.timestamp) > 1_s) {
_airspeed_filtered = 0.0f;
} else {
_airspeed_filtered = 0.95f * _airspeed_filtered + 0.05f * _airspeed_validated.true_airspeed_m_s;
}
// A leaking lowpass prevents biases from building up, but
// gives a mostly correct response for short impulses.