mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 16:03:34 +08:00
Cherry pick the directory and voted_sensors_update.h from PR #9756.
Consolidate _update_params() methods for improved inheritance from the LandDetector base class. Move common uORB::Subscriptions to the base class for inheritance. Deprecate redundant override methods.
This commit is contained in:
@@ -40,14 +40,6 @@
|
||||
|
||||
#include "LandDetector.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
namespace land_detector
|
||||
@@ -71,7 +63,7 @@ LandDetector::~LandDetector()
|
||||
|
||||
void LandDetector::start()
|
||||
{
|
||||
_check_params(true);
|
||||
_update_params(true);
|
||||
ScheduleOnInterval(LAND_DETECTOR_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
@@ -79,7 +71,7 @@ void LandDetector::Run()
|
||||
{
|
||||
perf_begin(_cycle_perf);
|
||||
|
||||
_check_params(false);
|
||||
_update_params();
|
||||
_actuator_armed_sub.update(&_actuator_armed);
|
||||
_update_topics();
|
||||
_update_state();
|
||||
@@ -149,16 +141,13 @@ void LandDetector::Run()
|
||||
}
|
||||
}
|
||||
|
||||
void LandDetector::_check_params(const bool force)
|
||||
void LandDetector::_update_params(const bool force)
|
||||
{
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated() || force) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
_update_params();
|
||||
parameter_update_s param_update;
|
||||
_parameter_update_sub.copy(¶m_update);
|
||||
|
||||
_update_total_flight_time();
|
||||
}
|
||||
@@ -192,6 +181,13 @@ void LandDetector::_update_state()
|
||||
}
|
||||
}
|
||||
|
||||
void LandDetector::_update_topics()
|
||||
{
|
||||
_actuator_armed_sub.update(&_actuator_armed);
|
||||
_vehicle_acceleration_sub.update(&_vehicle_acceleration);
|
||||
_vehicle_local_position_sub.update(&_vehicle_local_position);
|
||||
}
|
||||
|
||||
void LandDetector::_update_total_flight_time()
|
||||
{
|
||||
_total_flight_time = static_cast<uint64_t>(_param_total_flight_time_high.get()) << 32;
|
||||
|
||||
Reference in New Issue
Block a user