MultiCopterLandDetector: Implement ModuleParams inheritance (#12356)

This commit is contained in:
Mark Sauder
2019-08-09 07:57:42 +02:00
committed by Beat Küng
parent 2f222d6cbf
commit 056c8000a1
2 changed files with 41 additions and 57 deletions
@@ -52,6 +52,7 @@
#include <uORB/topics/actuator_controls.h>
#include <uORB/topics/battery_status.h>
#include <uORB/topics/parameter_update.h>
#include <uORB/topics/sensor_bias.h>
#include <uORB/topics/vehicle_acceleration.h>
#include <uORB/topics/vehicle_angular_velocity.h>
#include <uORB/topics/vehicle_attitude.h>
@@ -81,6 +82,14 @@ protected:
float _get_max_altitude() override;
private:
/* 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();
bool _has_position_lock();
bool _is_climb_rate_enabled();
/** Time in us that landing conditions have to hold before triggering a land. */
static constexpr hrt_abstime LAND_DETECTOR_TRIGGER_TIME_US = 300_ms;
@@ -97,35 +106,22 @@ private:
* @brief Handles for interesting parameters
**/
struct {
param_t maxClimbRate;
param_t maxVelocity;
param_t maxRotation;
param_t minThrottle;
param_t hoverThrottle;
param_t minManThrottle;
param_t freefall_acc_threshold;
param_t freefall_trigger_time;
param_t altitude_max;
param_t landSpeed;
param_t low_thrust_threshold;
} _paramHandle{};
struct {
float maxClimbRate;
float maxVelocity;
float maxRotation_rad_s;
float minThrottle;
float hoverThrottle;
float minManThrottle;
float freefall_acc_threshold;
float freefall_trigger_time;
float altitude_max;
float landSpeed;
float low_thrust_threshold;
} _params{};
uORB::Subscription _actuator_controls_sub{ORB_ID(actuator_controls_0)};
uORB::Subscription _battery_sub{ORB_ID(battery_status)};
uORB::Subscription _sensor_bias_sub{ORB_ID(sensor_bias)};
uORB::Subscription _vehicle_acceleration_sub{ORB_ID(vehicle_acceleration)};
uORB::Subscription _vehicle_angular_velocity_sub{ORB_ID(vehicle_angular_velocity)};
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)};
@@ -136,7 +132,7 @@ private:
actuator_controls_s _actuator_controls {};
battery_status_s _battery_status {};
vehicle_control_mode_s _control_mode {};
vehicle_acceleration_s _vehicle_acceleration{};
vehicle_acceleration_s _vehicle_acceleration{};
vehicle_attitude_s _vehicle_attitude {};
vehicle_angular_velocity_s _vehicle_angular_velocity{};
vehicle_local_position_s _vehicle_local_position {};
@@ -148,14 +144,16 @@ private:
bool _in_descend{false}; ///< vehicle is desending
bool _horizontal_movement{false}; ///< vehicle is moving horizontally
/* get control mode dependent pilot throttle threshold with which we should quit landed state and take off */
float _get_takeoff_throttle();
bool _has_altitude_lock();
bool _has_position_lock();
bool _has_minimal_thrust();
bool _has_low_thrust();
bool _is_climb_rate_enabled();
DEFINE_PARAMETERS_CUSTOM_PARENT(
LandDetector,
(ParamFloat<px4::params::LNDMC_ALT_MAX>) _param_lndmc_alt_max,
(ParamFloat<px4::params::LNDMC_FFALL_THR>) _param_lndmc_ffall_thr,
(ParamFloat<px4::params::LNDMC_FFALL_TTRI>) _param_lndmc_ffall_ttri,
(ParamFloat<px4::params::LNDMC_LOW_T_THR>) _param_lndmc_low_t_thr,
(ParamFloat<px4::params::LNDMC_ROT_MAX>) _param_lndmc_rot_max,
(ParamFloat<px4::params::LNDMC_XY_VEL_MAX>) _param_lndmc_xy_vel_max,
(ParamFloat<px4::params::LNDMC_Z_VEL_MAX>) _param_lndmc_z_vel_max
);
};
} // namespace land_detector