BatterySimulator: remove SimulatorBattery

It loads the battery parameters but then overwrites them
with hardcoded values and it breaks the ModuleParams
parent/child hierarchy. Both is undesired.
This commit is contained in:
Matthias Grob 2020-08-25 18:47:49 +02:00 committed by Daniel Agar
parent af9c6e6fce
commit 226f5f875d
3 changed files with 8 additions and 26 deletions

View File

@ -119,7 +119,7 @@ if [ $AUTOCNF = yes ]
then
param set SYS_AUTOSTART $REQUESTED_AUTOSTART
param set BAT_N_CELLS 3
param set BAT_N_CELLS 4
param set CAL_ACC0_ID 1311244
param set CAL_ACC_PRIME 1311244

View File

@ -35,7 +35,8 @@
BatterySimulator::BatterySimulator() :
ModuleParams(nullptr),
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default)
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default),
_battery(1, this, BATTERY_SIMLATOR_SAMPLE_INTERVAL_US)
{
}
@ -46,7 +47,7 @@ BatterySimulator::~BatterySimulator()
bool BatterySimulator::init()
{
ScheduleOnInterval(SimulatorBattery::SIMLATOR_BATTERY_SAMPLE_INTERVAL_US);
ScheduleOnInterval(BATTERY_SIMLATOR_SAMPLE_INTERVAL_US);
return true;
}

View File

@ -67,34 +67,15 @@ public:
private:
void Run() override;
static constexpr uint32_t BATTERY_SIMLATOR_SAMPLE_FREQUENCY_HZ = 100; // Hz
static constexpr uint32_t BATTERY_SIMLATOR_SAMPLE_INTERVAL_US = 1_s / BATTERY_SIMLATOR_SAMPLE_FREQUENCY_HZ;
uORB::Publication<battery_status_s> _battery_pub{ORB_ID(battery_status)};
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
class SimulatorBattery : public Battery
{
public:
static constexpr uint32_t SIMLATOR_BATTERY_SAMPLE_FREQUENCY_HZ = 100; // Hz
static constexpr uint32_t SIMLATOR_BATTERY_SAMPLE_INTERVAL_US = 1_s / SIMLATOR_BATTERY_SAMPLE_FREQUENCY_HZ;
SimulatorBattery() : Battery(1, nullptr, SIMLATOR_BATTERY_SAMPLE_INTERVAL_US) {}
virtual void updateParams() override
{
Battery::updateParams();
_params.v_empty = 3.5f;
_params.v_charged = 4.05f;
_params.n_cells = 4;
_params.capacity = 10.0f;
_params.v_load_drop = 0.0f;
_params.r_internal = 0.0f;
_params.low_thr = 0.15f;
_params.crit_thr = 0.07f;
_params.emergen_thr = 0.05f;
_params.source = 0;
}
} _battery;
Battery _battery;
uint64_t _last_integration_us{0};
float _battery_percentage{1.f};