battery: fetch throttle value inside of class

This commit is contained in:
Matthias Grob
2021-12-07 21:06:51 +01:00
parent ddc6b6bc9c
commit b965923c08
17 changed files with 38 additions and 81 deletions
@@ -71,7 +71,7 @@ AnalogBattery::AnalogBattery(int index, ModuleParams *parent, const int sample_i
void
AnalogBattery::updateBatteryStatusADC(hrt_abstime timestamp, float voltage_raw, float current_raw,
int source, int priority, float throttle_normalized)
int source, int priority)
{
float voltage_v = voltage_raw * _analog_params.v_div;
float current_a = (current_raw - _analog_params.v_offs_cur) * _analog_params.a_per_v;
@@ -81,7 +81,7 @@ AnalogBattery::updateBatteryStatusADC(hrt_abstime timestamp, float voltage_raw,
Battery::updateBatteryStatus(timestamp, voltage_v, current_a, connected,
source, priority, throttle_normalized);
source, priority);
}
bool AnalogBattery::is_valid()
+1 -2
View File
@@ -49,10 +49,9 @@ public:
* @param timestamp Time at which the ADC was read (use hrt_absolute_time())
* @param source The source as defined by param BAT%d_SOURCE
* @param priority: The brick number -1. The term priority refers to the Vn connection on the LTC4417
* @param throttle_normalized Throttle of the vehicle, between 0 and 1
*/
void updateBatteryStatusADC(hrt_abstime timestamp, float voltage_raw, float current_raw,
int source, int priority, float throttle_normalized);
int source, int priority);
/**
* Whether the ADC channel for the voltage of this battery is valid.
@@ -56,10 +56,9 @@
#include <lib/perf/perf_counter.h>
#include <lib/battery/battery.h>
#include <lib/conversion/rotation.h>
#include <uORB/Subscription.hpp>
#include <uORB/SubscriptionInterval.hpp>
#include <uORB/SubscriptionCallback.hpp>
#include <uORB/Publication.hpp>
#include <uORB/topics/actuator_controls.h>
#include <uORB/topics/parameter_update.h>
#include <uORB/topics/adc_report.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
@@ -100,7 +99,6 @@ public:
private:
void Run() override;
uORB::Subscription _actuator_ctrl_0_sub{ORB_ID(actuator_controls_0)}; /**< attitude controls sub */
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s}; /**< notification of parameter updates */
uORB::SubscriptionCallbackWorkItem _adc_report_sub{this, ORB_ID(adc_report)};
@@ -220,16 +218,12 @@ BatteryStatus::adc_poll()
for (int b = 0; b < BOARD_NUMBER_BRICKS; b++) {
actuator_controls_s ctrl{};
_actuator_ctrl_0_sub.copy(&ctrl);
_analogBatteries[b]->updateBatteryStatusADC(
hrt_absolute_time(),
bat_voltage_adc_readings[b],
bat_current_adc_readings[b],
battery_status_s::BATTERY_SOURCE_POWER_MODULE,
b,
ctrl.control[actuator_controls_s::INDEX_THROTTLE]
b
);
}
}