fix(land_detector): gravity-compensate FW horizontal acceleration check

This commit is contained in:
mahima-yoga authored and Mahima Yoga committed 2026-08-12 11:40:51 +02:00
1 parent 13f44d0d33
commit 4af02bf896
3 files changed
+19 -6

No files matched your search

@@ -41,6 +41,8 @@
#include "FixedwingLandDetector.h"
#include <lib/geo/geo.h>
namespace land_detector
{
@@ -121,10 +123,19 @@ bool FixedwingLandDetector::_get_landed_state()
_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.
const float acc_hor = matrix::Vector2f(_acceleration).norm();
_xy_accel_filtered = _xy_accel_filtered * 0.8f + acc_hor * 0.18f;
// rotate the body-frame specific force to the earth frame and add gravity back,
// such that a stationary vehicle measures ~0 at any attitude.
vehicle_attitude_s vehicle_attitude;
if (_vehicle_attitude_sub.copy(&vehicle_attitude)) {
const matrix::Vector3f accel_earth = matrix::Quatf(vehicle_attitude.q).rotateVector(_acceleration)
+ matrix::Vector3f(0.f, 0.f, CONSTANTS_ONE_G);
const float acc_hor = matrix::Vector2f(accel_earth.xy()).norm();
// A leaking lowpass prevents biases from building up, but
// gives a mostly correct response for short impulses.
_xy_accel_filtered = _xy_accel_filtered * 0.8f + acc_hor * 0.18f;
}
// Check for angular velocity
const float rot_vel_hor = _angular_velocity.norm();
@@ -46,6 +46,7 @@
#include <uORB/topics/airspeed_validated.h>
#include <uORB/topics/fixed_wing_runway_control.h>
#include <uORB/topics/launch_detection_status.h>
#include <uORB/topics/vehicle_attitude.h>
#include "LandDetector.h"
@@ -68,6 +69,7 @@ private:
uORB::Subscription _airspeed_validated_sub{ORB_ID(airspeed_validated)};
uORB::Subscription _launch_detection_status_sub{ORB_ID(launch_detection_status)};
uORB::Subscription _fixed_wing_runway_control_sub{ORB_ID(fixed_wing_runway_control)};
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)};
float _airspeed_filtered{0.0f};
float _velocity_xy_filtered{0.0f};
@@ -28,8 +28,8 @@ parameters:
LNDFW_XYACC_MAX:
description:
short: 'Fixed-wing land detector: Max horizontal acceleration'
long: Maximum horizontal (x,y body axes) acceleration allowed in the landed
state
long: Maximum gravity-compensated horizontal (earth frame) acceleration allowed
in the landed state.
type: float
default: 8.0
unit: m/s^2