Skip to content

Commit

Permalink
add airspeed finite checks before publication and VtolLandDetector usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Mar 26, 2018
1 parent 3b0dac9 commit aee32f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/modules/land_detector/VtolLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ bool VtolLandDetector::_get_landed_state()
bool landed = MulticopterLandDetector::_get_landed_state();

// for vtol we additionally consider airspeed
if (hrt_elapsed_time(&_airspeed.timestamp) < 500 * 1000 && _airspeed.confidence > 0.99f) {
_airspeed_filtered = 0.95f * _airspeed_filtered + 0.05f * _airspeed.true_airspeed_m_s;
if (hrt_elapsed_time(&_airspeed.timestamp) < 500 * 1000 && _airspeed.confidence > 0.99f
&& PX4_ISFINITE(_airspeed.indicated_airspeed_m_s)) {

_airspeed_filtered = 0.95f * _airspeed_filtered + 0.05f * _airspeed.indicated_airspeed_m_s;

} else {
// if airspeed does not update, set it to zero and rely on multicopter land detector
Expand All @@ -98,7 +100,7 @@ bool VtolLandDetector::_get_landed_state()

// only consider airspeed if we have been in air before to avoid false
// detections in the case of wind on the ground
if (_was_in_air && _airspeed_filtered > _params.maxAirSpeed) {
if (_was_in_air && (_airspeed_filtered > _params.maxAirSpeed)) {
landed = false;
}

Expand Down
6 changes: 4 additions & 2 deletions src/modules/sensors/sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ Sensors::diff_pres_poll(struct sensor_combined_s &raw)

airspeed.air_temperature_celsius = air_temperature_celsius;

int instance;
orb_publish_auto(ORB_ID(airspeed), &_airspeed_pub, &airspeed, &instance, ORB_PRIO_DEFAULT);
if (PX4_ISFINITE(airspeed.indicated_airspeed_m_s) && PX4_ISFINITE(airspeed.true_airspeed_m_s)) {
int instance;
orb_publish_auto(ORB_ID(airspeed), &_airspeed_pub, &airspeed, &instance, ORB_PRIO_DEFAULT);
}
}
}

Expand Down

0 comments on commit aee32f4

Please sign in to comment.