mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 17:29:07 +08:00
Only publish battery if we can measure something, initialize battery topic in commander correctly
This commit is contained in:
parent
4b0f1a6fb1
commit
19f2a7bff0
@ -198,15 +198,15 @@ static uint64_t _inair_last_time = 0;
|
||||
static float eph_threshold = 5.0f;
|
||||
static float epv_threshold = 10.0f;
|
||||
|
||||
static struct vehicle_status_s status;
|
||||
static struct battery_status_s battery;
|
||||
static struct actuator_armed_s armed;
|
||||
static struct safety_s safety;
|
||||
static struct vehicle_control_mode_s control_mode;
|
||||
static struct offboard_control_mode_s offboard_control_mode;
|
||||
static struct home_position_s _home;
|
||||
static struct vehicle_status_s status = {};
|
||||
static struct battery_status_s battery = {};
|
||||
static struct actuator_armed_s armed = {};
|
||||
static struct safety_s safety = {};
|
||||
static struct vehicle_control_mode_s control_mode = {};
|
||||
static struct offboard_control_mode_s offboard_control_mode = {};
|
||||
static struct home_position_s _home = {};
|
||||
static int32_t _flight_mode_slots[manual_control_setpoint_s::MODE_SLOT_MAX];
|
||||
static struct commander_state_s internal_state;
|
||||
static struct commander_state_s internal_state = {};
|
||||
|
||||
static unsigned _last_mission_instance = 0;
|
||||
static manual_control_setpoint_s _last_sp_man = {};
|
||||
|
||||
@ -1657,11 +1657,12 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
if (ADC_BATTERY_VOLTAGE_CHANNEL == buf_adc[i].am_channel) {
|
||||
/* Voltage in volts */
|
||||
bat_voltage_v = (buf_adc[i].am_data * _parameters.battery_voltage_scaling);
|
||||
updated_battery = true;
|
||||
if (bat_voltage_v > 0.5f) {
|
||||
updated_battery = true;
|
||||
}
|
||||
|
||||
} else if (ADC_BATTERY_CURRENT_CHANNEL == buf_adc[i].am_channel) {
|
||||
bat_current_a = (buf_adc[i].am_data * _parameters.battery_current_scaling);
|
||||
updated_battery = true;
|
||||
|
||||
#ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user