diff --git a/src/lib/battery/battery.cpp b/src/lib/battery/battery.cpp index 2ed157dee4..3ea9f69c60 100644 --- a/src/lib/battery/battery.cpp +++ b/src/lib/battery/battery.cpp @@ -113,6 +113,14 @@ void Battery::updateCurrent(const float current_a) void Battery::updateBatteryStatus(const hrt_abstime ×tamp) { + if (_parameter_update_sub.updated()) { + // Read from topic to clear updated flag + parameter_update_s parameter_update; + _parameter_update_sub.copy(¶meter_update); + + updateParams(); + } + if (!_battery_initialized) { _voltage_filter_v.reset(_voltage_v); _current_filter_a.reset(_current_a); diff --git a/src/lib/battery/battery.h b/src/lib/battery/battery.h index 26dc4e3e61..762c9bf5f5 100644 --- a/src/lib/battery/battery.h +++ b/src/lib/battery/battery.h @@ -58,6 +58,10 @@ #include #include #include +#include +#include + +using namespace time_literals; /** * BatteryBase is a base class for any type of battery. @@ -156,6 +160,7 @@ private: uORB::Subscription _vehicle_thrust_setpoint_0_sub{ORB_ID(vehicle_thrust_setpoint)}; uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)}; uORB::PublicationMulti _battery_status_pub{ORB_ID(battery_status)}; + uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s}; bool _external_state_of_charge{false}; ///< inticates that the soc is injected and not updated by this library