mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 06:14:14 +08:00
fix multicopter land detector: do not update parameters every cycle (#13212)
And add updateParams() call in LandDetector::_update_params().
This commit is contained in:
@@ -57,7 +57,7 @@ LandDetector::~LandDetector()
|
||||
|
||||
void LandDetector::start()
|
||||
{
|
||||
_update_params(true);
|
||||
_update_params();
|
||||
ScheduleOnInterval(LAND_DETECTOR_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,10 @@ void LandDetector::Run()
|
||||
{
|
||||
perf_begin(_cycle_perf);
|
||||
|
||||
_update_params();
|
||||
if (_parameter_update_sub.updated()) {
|
||||
_update_params();
|
||||
}
|
||||
|
||||
_actuator_armed_sub.update(&_actuator_armed);
|
||||
_update_topics();
|
||||
_update_state();
|
||||
@@ -131,16 +134,13 @@ void LandDetector::Run()
|
||||
}
|
||||
}
|
||||
|
||||
void LandDetector::_update_params(const bool force)
|
||||
void LandDetector::_update_params()
|
||||
{
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated() || force) {
|
||||
// clear update
|
||||
parameter_update_s param_update;
|
||||
_parameter_update_sub.copy(¶m_update);
|
||||
parameter_update_s param_update;
|
||||
_parameter_update_sub.copy(¶m_update);
|
||||
|
||||
_update_total_flight_time();
|
||||
}
|
||||
updateParams();
|
||||
_update_total_flight_time();
|
||||
}
|
||||
|
||||
void LandDetector::_update_state()
|
||||
|
||||
@@ -97,10 +97,9 @@ public:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Updates parameters if changes have occurred or if forced.
|
||||
* @var force Forces a parameter update.
|
||||
* Updates parameters.
|
||||
*/
|
||||
virtual void _update_params(const bool force = false);
|
||||
virtual void _update_params();
|
||||
|
||||
/**
|
||||
* Updates subscribed uORB topics.
|
||||
@@ -148,6 +147,7 @@ protected:
|
||||
|
||||
actuator_armed_s _actuator_armed{};
|
||||
vehicle_acceleration_s _vehicle_acceleration{};
|
||||
|
||||
vehicle_land_detected_s _land_detected = {
|
||||
.timestamp = 0,
|
||||
.alt_max = -1.0f,
|
||||
@@ -156,14 +156,11 @@ protected:
|
||||
.maybe_landed = true,
|
||||
.landed = true,
|
||||
};
|
||||
|
||||
vehicle_local_position_s _vehicle_local_position{};
|
||||
|
||||
uORB::Publication<vehicle_land_detected_s> _vehicle_land_detected_pub{ORB_ID(vehicle_land_detected)};
|
||||
|
||||
uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
|
||||
uORB::Subscription _vehicle_acceleration_sub{ORB_ID(vehicle_acceleration)};
|
||||
uORB::Subscription _vehicle_local_position_sub{ORB_ID(vehicle_local_position)};
|
||||
|
||||
private:
|
||||
|
||||
void Run() override;
|
||||
@@ -179,7 +176,10 @@ private:
|
||||
|
||||
perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, "land_detector_cycle")};
|
||||
|
||||
uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _vehicle_acceleration_sub{ORB_ID(vehicle_acceleration)};
|
||||
uORB::Subscription _vehicle_local_position_sub{ORB_ID(vehicle_local_position)};
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(
|
||||
ModuleParams,
|
||||
|
||||
@@ -95,9 +95,9 @@ void MulticopterLandDetector::_update_topics()
|
||||
_vehicle_local_position_setpoint_sub.update(&_vehicle_local_position_setpoint);
|
||||
}
|
||||
|
||||
void MulticopterLandDetector::_update_params(const bool force)
|
||||
void MulticopterLandDetector::_update_params()
|
||||
{
|
||||
LandDetector::_update_params(force);
|
||||
LandDetector::_update_params();
|
||||
|
||||
_freefall_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1e6f * _param_lndmc_ffall_ttri.get()));
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
MulticopterLandDetector();
|
||||
|
||||
protected:
|
||||
void _update_params(const bool force = false) override;
|
||||
void _update_params() override;
|
||||
void _update_topics() override;
|
||||
|
||||
bool _get_landed_state() override;
|
||||
|
||||
Reference in New Issue
Block a user