mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 09:43:34 +08:00
Rename _accel_horz_lp -> _xy_accel_filtered to standardize naming, use time literal, and delete unneeded #includes in the FixedwingLandDetector class.
This commit is contained in:
@@ -39,14 +39,10 @@
|
|||||||
* @author Julian Oes <julian@oes.ch>
|
* @author Julian Oes <julian@oes.ch>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FixedwingLandDetector.h"
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <px4_config.h>
|
|
||||||
#include <px4_defines.h>
|
|
||||||
#include <matrix/math.hpp>
|
#include <matrix/math.hpp>
|
||||||
|
|
||||||
|
#include "FixedwingLandDetector.h"
|
||||||
|
|
||||||
namespace land_detector
|
namespace land_detector
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -90,7 +86,7 @@ bool FixedwingLandDetector::_get_landed_state()
|
|||||||
|
|
||||||
bool landDetected = false;
|
bool landDetected = false;
|
||||||
|
|
||||||
if (hrt_elapsed_time(&_vehicle_local_position.timestamp) < 500 * 1000) {
|
if (hrt_elapsed_time(&_vehicle_local_position.timestamp) < 500_ms) {
|
||||||
|
|
||||||
// Horizontal velocity complimentary filter.
|
// Horizontal velocity complimentary filter.
|
||||||
float val = 0.97f * _velocity_xy_filtered + 0.03f * sqrtf(_vehicle_local_position.vx * _vehicle_local_position.vx +
|
float val = 0.97f * _velocity_xy_filtered + 0.03f * sqrtf(_vehicle_local_position.vx * _vehicle_local_position.vx +
|
||||||
@@ -114,10 +110,10 @@ bool FixedwingLandDetector::_get_landed_state()
|
|||||||
const matrix::Vector3f accel{_vehicle_acceleration.xyz};
|
const matrix::Vector3f accel{_vehicle_acceleration.xyz};
|
||||||
const float acc_hor = sqrtf(accel(0) * accel(0) + accel(1) * accel(1));
|
const float acc_hor = sqrtf(accel(0) * accel(0) + accel(1) * accel(1));
|
||||||
|
|
||||||
_accel_horz_lp = _accel_horz_lp * 0.8f + acc_hor * 0.18f;
|
_xy_accel_filtered = _xy_accel_filtered * 0.8f + acc_hor * 0.18f;
|
||||||
|
|
||||||
// crude land detector for fixedwing
|
// crude land detector for fixedwing
|
||||||
landDetected = _accel_horz_lp < _param_lndfw_xyaccel_max.get()
|
landDetected = _xy_accel_filtered < _param_lndfw_xyaccel_max.get()
|
||||||
&& _airspeed_filtered < _param_lndfw_airspd.get()
|
&& _airspeed_filtered < _param_lndfw_airspd.get()
|
||||||
&& _velocity_xy_filtered < _param_lndfw_vel_xy_max.get()
|
&& _velocity_xy_filtered < _param_lndfw_vel_xy_max.get()
|
||||||
&& _velocity_z_filtered < _param_lndfw_vel_z_max.get();
|
&& _velocity_z_filtered < _param_lndfw_vel_z_max.get();
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <drivers/drv_hrt.h>
|
|
||||||
#include <uORB/Subscription.hpp>
|
#include <uORB/Subscription.hpp>
|
||||||
#include <uORB/topics/airspeed.h>
|
#include <uORB/topics/airspeed.h>
|
||||||
#include <uORB/topics/vehicle_acceleration.h>
|
#include <uORB/topics/vehicle_acceleration.h>
|
||||||
@@ -82,10 +81,10 @@ private:
|
|||||||
vehicle_acceleration_s _vehicle_acceleration{};
|
vehicle_acceleration_s _vehicle_acceleration{};
|
||||||
vehicle_local_position_s _vehicle_local_position{};
|
vehicle_local_position_s _vehicle_local_position{};
|
||||||
|
|
||||||
float _accel_horz_lp{0.0f};
|
|
||||||
float _airspeed_filtered{0.0f};
|
float _airspeed_filtered{0.0f};
|
||||||
float _velocity_xy_filtered{0.0f};
|
float _velocity_xy_filtered{0.0f};
|
||||||
float _velocity_z_filtered{0.0f};
|
float _velocity_z_filtered{0.0f};
|
||||||
|
float _xy_accel_filtered{0.0f};
|
||||||
|
|
||||||
DEFINE_PARAMETERS_CUSTOM_PARENT(
|
DEFINE_PARAMETERS_CUSTOM_PARENT(
|
||||||
LandDetector,
|
LandDetector,
|
||||||
|
|||||||
Reference in New Issue
Block a user