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

Implement ModuleParams inheritance in the VtolLandDetector class. #12379

Merged
merged 1 commit into from
Aug 14, 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
1 change: 1 addition & 0 deletions src/modules/land_detector/MulticopterLandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class MulticopterLandDetector : public LandDetector

/* get control mode dependent pilot throttle threshold with which we should quit landed state and take off */
float _get_takeoff_throttle();

bool _has_low_thrust();
bool _has_minimal_thrust();
bool _has_altitude_lock();
Expand Down
11 changes: 1 addition & 10 deletions src/modules/land_detector/VtolLandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ namespace land_detector

VtolLandDetector::VtolLandDetector()
{
_paramHandle.maxAirSpeed = param_find("LNDFW_AIRSPD_MAX");
}

void VtolLandDetector::_update_topics()
{
MulticopterLandDetector::_update_topics();

_airspeed_sub.update(&_airspeed);
_vehicle_status_sub.update(&_vehicle_status);
}
Expand Down Expand Up @@ -92,7 +90,7 @@ bool VtolLandDetector::_get_landed_state()

// only consider airspeed if we have been in air before to avoid false
// detections in the case of wind on the ground
if (_was_in_air && (_airspeed_filtered > _params.maxAirSpeed)) {
if (_was_in_air && (_airspeed_filtered > _param_lndfw_airspd_max.get())) {
landed = false;
}

Expand All @@ -101,11 +99,4 @@ bool VtolLandDetector::_get_landed_state()
return landed;
}

void VtolLandDetector::_update_params()
{
MulticopterLandDetector::_update_params();

param_get(_paramHandle.maxAirSpeed, &_params.maxAirSpeed);
}

} // namespace land_detector
14 changes: 5 additions & 9 deletions src/modules/land_detector/VtolLandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,11 @@ class VtolLandDetector : public MulticopterLandDetector
VtolLandDetector();

protected:
void _update_params() override;
void _update_topics() override;
bool _get_landed_state() override;
bool _get_maybe_landed_state() override;

private:
struct {
param_t maxAirSpeed;
} _paramHandle{};

struct {
float maxAirSpeed;
} _params{};

uORB::Subscription _airspeed_sub{ORB_ID(airspeed)};
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
Expand All @@ -78,7 +70,11 @@ class VtolLandDetector : public MulticopterLandDetector

bool _was_in_air{false}; /**< indicates whether the vehicle was in the air in the previous iteration */
float _airspeed_filtered{0.0f}; /**< low pass filtered airspeed */
};

DEFINE_PARAMETERS_CUSTOM_PARENT(
MulticopterLandDetector,
(ParamFloat<px4::params::LNDFW_AIRSPD_MAX>) _param_lndfw_airspd_max
);
};

} // namespace land_detector