mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 00:43:34 +08:00
Make all battery sensor drivers report their sample interval
To make use of the time abstraction in the leaky integrator.
This commit is contained in:
@@ -38,7 +38,7 @@ using namespace time_literals;
|
||||
EscBattery::EscBattery() :
|
||||
ModuleParams(nullptr),
|
||||
WorkItem(MODULE_NAME, px4::wq_configurations::lp_default),
|
||||
_battery(1, this)
|
||||
_battery(1, this, ESC_BATTERY_INTERVAL_US)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ EscBattery::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
_esc_status_sub.set_interval_us(ESC_BATTERY_INTERVAL_US);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <battery/battery.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
class EscBattery : public ModuleBase<EscBattery>, public ModuleParams, public px4::WorkItem
|
||||
{
|
||||
public:
|
||||
@@ -73,5 +75,6 @@ private:
|
||||
uORB::Subscription _actuator_ctrl_0_sub{ORB_ID(actuator_controls_0)};
|
||||
uORB::SubscriptionCallbackWorkItem _esc_status_sub{this, ORB_ID(esc_status)};
|
||||
|
||||
static constexpr uint32_t ESC_BATTERY_INTERVAL_US = 20_ms; // assume higher frequency esc feedback than 50Hz
|
||||
Battery _battery;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user