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

FW LandDetector: disregard horizontal velocity if local_position.v_xy_valid is false #24133

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 24 additions & 9 deletions src/modules/land_detector/FixedwingLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ bool FixedwingLandDetector::_get_landed_state()

} else if (hrt_elapsed_time(&_vehicle_local_position.timestamp) < 1_s) {

// Horizontal velocity complimentary filter.
float val = 0.97f * _velocity_xy_filtered + 0.03f * sqrtf(_vehicle_local_position.vx * _vehicle_local_position.vx +
_vehicle_local_position.vy * _vehicle_local_position.vy);
float val = 0.0f;

if (_vehicle_local_position.v_xy_valid) {
// Horizontal velocity complimentary filter.
val = 0.97f * _velocity_xy_filtered + 0.03f * sqrtf(_vehicle_local_position.vx * _vehicle_local_position.vx +
_vehicle_local_position.vy * _vehicle_local_position.vy);
}

if (PX4_ISFINITE(val)) {
_velocity_xy_filtered = val;
Expand Down Expand Up @@ -105,15 +109,26 @@ bool FixedwingLandDetector::_get_landed_state()
const float acc_hor = matrix::Vector2f(_acceleration).norm();
_xy_accel_filtered = _xy_accel_filtered * 0.8f + acc_hor * 0.18f;

// Check for angular velocity
const float rot_vel_hor = _angular_velocity.norm();
val = _velocity_rot_filtered * 0.95f + rot_vel_hor * 0.05f;

if (PX4_ISFINITE(val)) {
_velocity_rot_filtered = val;
}

// make groundspeed threshold tighter if airspeed is invalid
const float vel_xy_max_threshold = airspeed_invalid ? 0.7f * _param_lndfw_vel_xy_max.get() :
_param_lndfw_vel_xy_max.get();
const float vel_xy_max_threshold = airspeed_invalid ? 0.7f * _param_lndfw_vel_xy_max.get() :
_param_lndfw_vel_xy_max.get();

const float max_rotation_threshold = math::radians(_param_lndfw_rot_max.get()) ;

// Crude land detector for fixedwing.
landDetected = _airspeed_filtered < _param_lndfw_airspd.get()
&& _velocity_xy_filtered < vel_xy_max_threshold
&& _velocity_z_filtered < _param_lndfw_vel_z_max.get()
&& _xy_accel_filtered < _param_lndfw_xyaccel_max.get();
landDetected = _airspeed_filtered < _param_lndfw_airspd.get()
&& _velocity_xy_filtered < vel_xy_max_threshold
&& _velocity_z_filtered < _param_lndfw_vel_z_max.get()
&& _xy_accel_filtered < _param_lndfw_xyaccel_max.get()
&& _velocity_rot_filtered < max_rotation_threshold;

} else {
// Control state topic has timed out and we need to assume we're landed.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/land_detector/FixedwingLandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ class FixedwingLandDetector final : public LandDetector
float _velocity_xy_filtered{0.0f};
float _velocity_z_filtered{0.0f};
float _xy_accel_filtered{0.0f};
float _velocity_rot_filtered{0.0f};

DEFINE_PARAMETERS_CUSTOM_PARENT(
LandDetector,
(ParamFloat<px4::params::LNDFW_XYACC_MAX>) _param_lndfw_xyaccel_max,
(ParamFloat<px4::params::LNDFW_AIRSPD_MAX>) _param_lndfw_airspd,
(ParamFloat<px4::params::LNDFW_VEL_XY_MAX>) _param_lndfw_vel_xy_max,
(ParamFloat<px4::params::LNDFW_VEL_Z_MAX>) _param_lndfw_vel_z_max,
(ParamFloat<px4::params::LNDFW_ROT_MAX>) _param_lndfw_rot_max,
(ParamFloat<px4::params::LNDFW_TRIG_TIME>) _param_lndfw_trig_time
);
};
Expand Down
11 changes: 11 additions & 0 deletions src/modules/land_detector/land_detector_params_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,14 @@ PARAM_DEFINE_FLOAT(LNDFW_AIRSPD_MAX, 6.00f);
* @group Land Detector
*/
PARAM_DEFINE_FLOAT(LNDFW_TRIG_TIME, 2.f);

/**
* Fixed-wing land detector: max rotational speed
*
* Maximum allowed norm of the angular velocity in the landed state.
*
* @unit deg/s
* @decimal 1
* @group Land Detector
*/
PARAM_DEFINE_FLOAT(LNDFW_ROT_MAX, 0.5f);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Threshold based on logs of 8 FW flights. Highest value that results in 0 false positives.

If it's too low, could consider increasing default hysteresis time to transition into landed state, because false positives for higher thresholds are mostly non-consecutive - but I don't know if it makes sense to do that.

4 changes: 2 additions & 2 deletions src/modules/land_detector/land_detector_params_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ PARAM_DEFINE_FLOAT(LNDMC_Z_VEL_MAX, 0.25f);
PARAM_DEFINE_FLOAT(LNDMC_XY_VEL_MAX, 1.5f);

/**
* Multicopter max rotation
* Multicopter max rotational speed
*
* Maximum allowed angular velocity around each axis allowed in the landed state.
* Maximum allowed norm of the angular velocity (roll, pitch) in the landed state.
*
* @unit deg/s
* @decimal 1
Expand Down
Loading