mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-02 06:10:45 +08:00
feat(land_detector): detect movement from the specific force change
The vibration metrics miss smooth accelerations such as a fixed-wing takeoff roll, which let at_rest be declared while moving.
This commit is contained in:
1 parent
eaff7221eb
commit
745d4c4c8a
2 files changed
+24
No files matched your search
@@ -103,6 +103,25 @@ void LandDetector::Run()
|
||||
|
||||
if (_vehicle_acceleration_sub.update(&vehicle_acceleration)) {
|
||||
_acceleration = matrix::Vector3f{vehicle_acceleration.xyz};
|
||||
|
||||
const bool first_sample = (_time_last_acceleration_sample_us == 0);
|
||||
const float dt_s = (vehicle_acceleration.timestamp_sample - _time_last_acceleration_sample_us) * 1e-6f;
|
||||
_time_last_acceleration_sample_us = vehicle_acceleration.timestamp_sample;
|
||||
|
||||
if (first_sample || (dt_s > 1.f)) {
|
||||
_specific_force_fast.reset(_acceleration);
|
||||
_specific_force_slow.reset(_acceleration);
|
||||
}
|
||||
|
||||
// Catches smooth accelerations, such as a takeoff roll, that the high-passed vibration metrics miss.
|
||||
static constexpr float kSpecificForceChangeMax = 0.3f;
|
||||
|
||||
const matrix::Vector3f specific_force_change = _specific_force_fast.update(_acceleration, dt_s)
|
||||
- _specific_force_slow.update(_acceleration, dt_s);
|
||||
|
||||
if (specific_force_change.longerThan(kSpecificForceChangeMax)) {
|
||||
_time_last_move_detect_us = vehicle_acceleration.timestamp_sample;
|
||||
}
|
||||
}
|
||||
|
||||
vehicle_angular_velocity_s vehicle_angular_velocity{};
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <lib/hysteresis/hysteresis.h>
|
||||
#include <lib/mathlib/math/filter/AlphaFilter.hpp>
|
||||
#include <lib/perf/perf_counter.h>
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
@@ -167,6 +168,10 @@ private:
|
||||
hrt_abstime _total_flight_time{0}; ///< total vehicle flight time in microseconds
|
||||
|
||||
hrt_abstime _time_last_move_detect_us{0}; // timestamp of last movement detection event in microseconds
|
||||
hrt_abstime _time_last_acceleration_sample_us{0};
|
||||
|
||||
AlphaFilter<matrix::Vector3f> _specific_force_fast{0.5f};
|
||||
AlphaFilter<matrix::Vector3f> _specific_force_slow{5.f};
|
||||
|
||||
perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")};
|
||||
|
||||
|
||||
Reference in new issue
Block a user