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

Rename _accel_horz_lp -> _xy_accel_filtered, delete unneeded #includes in FixedwingLandDetector #12702

Merged
merged 1 commit into from
Aug 15, 2019
Merged
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
14 changes: 5 additions & 9 deletions src/modules/land_detector/FixedwingLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@
* @author Julian Oes <[email protected]>
*/

#include "FixedwingLandDetector.h"

#include <cmath>

#include <px4_config.h>
#include <px4_defines.h>
#include <matrix/math.hpp>

#include "FixedwingLandDetector.h"

namespace land_detector
{

Expand Down Expand Up @@ -90,7 +86,7 @@ bool FixedwingLandDetector::_get_landed_state()

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.
float val = 0.97f * _velocity_xy_filtered + 0.03f * sqrtf(_vehicle_local_position.vx * _vehicle_local_position.vx +
Expand All @@ -114,10 +110,10 @@ bool FixedwingLandDetector::_get_landed_state()
const matrix::Vector3f accel{_vehicle_acceleration.xyz};
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
landDetected = _accel_horz_lp < _param_lndfw_xyaccel_max.get()
landDetected = _xy_accel_filtered < _param_lndfw_xyaccel_max.get()
&& _airspeed_filtered < _param_lndfw_airspd.get()
&& _velocity_xy_filtered < _param_lndfw_vel_xy_max.get()
&& _velocity_z_filtered < _param_lndfw_vel_z_max.get();
Expand Down
3 changes: 1 addition & 2 deletions src/modules/land_detector/FixedwingLandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

#pragma once

#include <drivers/drv_hrt.h>
#include <uORB/Subscription.hpp>
#include <uORB/topics/airspeed.h>
#include <uORB/topics/vehicle_acceleration.h>
Expand Down Expand Up @@ -82,10 +81,10 @@ class FixedwingLandDetector final : public LandDetector
vehicle_acceleration_s _vehicle_acceleration{};
vehicle_local_position_s _vehicle_local_position{};

float _accel_horz_lp{0.0f};
float _airspeed_filtered{0.0f};
float _velocity_xy_filtered{0.0f};
float _velocity_z_filtered{0.0f};
float _xy_accel_filtered{0.0f};

DEFINE_PARAMETERS_CUSTOM_PARENT(
LandDetector,
Expand Down