Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTOL land detector: disable freefall detection if FW and move to airspeed_validated #14031

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/modules/land_detector/VtolLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*/

#include <drivers/drv_hrt.h>
#include <matrix/math.hpp>

#include "VtolLandDetector.h"

Expand All @@ -49,7 +50,7 @@ namespace land_detector
void VtolLandDetector::_update_topics()
{
MulticopterLandDetector::_update_topics();
_airspeed_sub.update(&_airspeed);
_airspeed_validated_sub.update(&_airspeed_validated);
_vehicle_status_sub.update(&_vehicle_status);
}

Expand All @@ -74,10 +75,9 @@ bool VtolLandDetector::_get_landed_state()
bool landed = MulticopterLandDetector::_get_landed_state();

// for vtol we additionally consider airspeed
if (hrt_elapsed_time(&_airspeed.timestamp) < 1_s && _airspeed.confidence > 0.99f
&& PX4_ISFINITE(_airspeed.indicated_airspeed_m_s)) {
if (hrt_elapsed_time(&_airspeed_validated.timestamp) < 1_s && PX4_ISFINITE(_airspeed_validated.true_airspeed_m_s)) {

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

} else {
// if airspeed does not update, set it to zero and rely on multicopter land detector
Expand All @@ -95,4 +95,13 @@ bool VtolLandDetector::_get_landed_state()
return landed;
}

bool VtolLandDetector::_get_freefall_state()
{
bool free_fall_detected =
MulticopterLandDetector::_get_freefall_state(); // true if falling or in a parabolic flight (low gravity)

// only return a positive free fall detected if not in fixed-wing mode
return _vehicle_status.vehicle_type != vehicle_status_s::VEHICLE_TYPE_FIXED_WING && free_fall_detected;
}

} // namespace land_detector
7 changes: 4 additions & 3 deletions src/modules/land_detector/VtolLandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#pragma once

#include <uORB/topics/airspeed.h>
#include <uORB/topics/airspeed_validated.h>
#include <uORB/topics/vehicle_status.h>

#include "MulticopterLandDetector.h"
Expand All @@ -59,13 +59,14 @@ class VtolLandDetector : public MulticopterLandDetector
void _update_topics() override;
bool _get_landed_state() override;
bool _get_maybe_landed_state() override;
bool _get_freefall_state() override;

private:

uORB::Subscription _airspeed_sub{ORB_ID(airspeed)};
uORB::Subscription _airspeed_validated_sub{ORB_ID(airspeed_validated)};
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};

airspeed_s _airspeed{};
airspeed_validated_s _airspeed_validated{};
vehicle_status_s _vehicle_status{};

bool _was_in_air{false}; /**< indicates whether the vehicle was in the air in the previous iteration */
Expand Down