Skip to content

Commit

Permalink
Disregard horizontal velocity if local_position.v_xy_valid is false
Browse files Browse the repository at this point in the history
  • Loading branch information
mahimayoga committed Dec 19, 2024
1 parent 93c25ef commit 5e0a392
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/modules/land_detector/FixedwingLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ 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;

if (!_vehicle_local_position.v_xy_valid) {
// set _velocity_xy_filtered to 0 if data is invalid
val = 0.0f;
} else {
// 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

0 comments on commit 5e0a392

Please sign in to comment.