mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 03:13:34 +08:00
sensors: only publish battery topic if valid
This commit is contained in:
@@ -1709,17 +1709,18 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
|||||||
// removed, or it needs to be subscribed to actuator controls.
|
// removed, or it needs to be subscribed to actuator controls.
|
||||||
const float throttle = 0.0f;
|
const float throttle = 0.0f;
|
||||||
_battery.updateBatteryStatus(t, bat_voltage_v, bat_current_a, throttle, &_battery_status);
|
_battery.updateBatteryStatus(t, bat_voltage_v, bat_current_a, throttle, &_battery_status);
|
||||||
|
|
||||||
|
/* announce the battery status if needed, just publish else */
|
||||||
|
if (_battery_pub != nullptr) {
|
||||||
|
orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_battery_pub = orb_advertise(ORB_ID(battery_status), &_battery_status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_last_adc = t;
|
_last_adc = t;
|
||||||
|
|
||||||
/* announce the battery status if needed, just publish else */
|
|
||||||
if (_battery_pub != nullptr) {
|
|
||||||
orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
_battery_pub = orb_advertise(ORB_ID(battery_status), &_battery_status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user