Client: Catch ValueError when count battery percentage

This commit is contained in:
Arthur Golubtsov
2019-11-05 22:49:40 +00:00
parent 34ad8bd5ef
commit 4db18395eb

View File

@@ -672,7 +672,10 @@ def telemetry_loop():
batt_empty = batt_empty_param.value.real
batt_charged = batt_charged_param.value.real
batt_cells = batt_cells_param.value.integer
telemetry = telemetry._replace(battery_p = '{}'.format(int(min((ros_telemetry.voltage/batt_cells - batt_empty)/(batt_charged - batt_empty)*100., 100))))
try:
telemetry = telemetry._replace(battery_p = '{}'.format(int(min((ros_telemetry.voltage/batt_cells - batt_empty)/(batt_charged - batt_empty)*100., 100))))
except ValueError:
telemetry = telemetry._replace(battery_p = 'nan')
else:
telemetry = telemetry._replace(battery_p = 'nan')
telemetry = telemetry._replace(calibration_status = get_calibration_status())