mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
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:
committed by
Daniel Agar
parent
af9c6e6fce
commit
226f5f875d
@@ -119,7 +119,7 @@ if [ $AUTOCNF = yes ]
|
|||||||
then
|
then
|
||||||
param set SYS_AUTOSTART $REQUESTED_AUTOSTART
|
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_ACC0_ID 1311244
|
||||||
param set CAL_ACC_PRIME 1311244
|
param set CAL_ACC_PRIME 1311244
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
|
|
||||||
BatterySimulator::BatterySimulator() :
|
BatterySimulator::BatterySimulator() :
|
||||||
ModuleParams(nullptr),
|
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()
|
bool BatterySimulator::init()
|
||||||
{
|
{
|
||||||
ScheduleOnInterval(SimulatorBattery::SIMLATOR_BATTERY_SAMPLE_INTERVAL_US);
|
ScheduleOnInterval(BATTERY_SIMLATOR_SAMPLE_INTERVAL_US);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,34 +67,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
void Run() override;
|
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::Publication<battery_status_s> _battery_pub{ORB_ID(battery_status)};
|
||||||
|
|
||||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||||
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
||||||
|
|
||||||
class SimulatorBattery : public Battery
|
Battery _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;
|
|
||||||
|
|
||||||
uint64_t _last_integration_us{0};
|
uint64_t _last_integration_us{0};
|
||||||
float _battery_percentage{1.f};
|
float _battery_percentage{1.f};
|
||||||
|
|||||||
Reference in New Issue
Block a user