mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-10 09:58:28 -04:00
autotest: add test for FRSkyD battery
This commit is contained in:
parent
0a922426a2
commit
cccec5c21c
@ -10372,20 +10372,50 @@ switch value'''
|
|||||||
if m is None:
|
if m is None:
|
||||||
raise NotAchievedException("Did not receive GLOBAL_POSITION_INT")
|
raise NotAchievedException("Did not receive GLOBAL_POSITION_INT")
|
||||||
gpi_abs_alt = int((m.alt+500) / 1000) # mm -> m
|
gpi_abs_alt = int((m.alt+500) / 1000) # mm -> m
|
||||||
|
|
||||||
|
# grab a battery-remaining percentage
|
||||||
|
self.run_cmd(mavutil.mavlink.MAV_CMD_BATTERY_RESET,
|
||||||
|
255, # battery mask
|
||||||
|
96, # percentage
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
m = self.mav.recv_match(type='BATTERY_STATUS', blocking=True, timeout=1)
|
||||||
|
if m is None:
|
||||||
|
raise NotAchievedException("Did not receive BATTERY_STATUS")
|
||||||
|
want_battery_remaining_pct = m.battery_remaining
|
||||||
|
|
||||||
tstart = self.get_sim_time_cached()
|
tstart = self.get_sim_time_cached()
|
||||||
|
have_alt = False
|
||||||
|
have_battery = False
|
||||||
while True:
|
while True:
|
||||||
t2 = self.get_sim_time_cached()
|
t2 = self.get_sim_time_cached()
|
||||||
if t2 - tstart > 10:
|
if t2 - tstart > 10:
|
||||||
raise AutoTestTimeoutException("Failed to get frsky D data")
|
raise AutoTestTimeoutException("Failed to get frsky D data")
|
||||||
frsky.update()
|
frsky.update()
|
||||||
|
|
||||||
alt = frsky.get_data(frsky.dataid_GPS_ALT_BP)
|
alt = frsky.get_data(frsky.dataid_GPS_ALT_BP)
|
||||||
self.progress("Got alt (%s) mav=%s" % (str(alt), str(gpi_abs_alt)))
|
self.progress("Got alt (%s) mav=%s" % (str(alt), str(gpi_abs_alt)))
|
||||||
if alt is None:
|
if alt is None:
|
||||||
continue
|
continue
|
||||||
self.drain_mav_unparsed()
|
|
||||||
if alt == gpi_abs_alt:
|
if alt == gpi_abs_alt:
|
||||||
|
have_alt = True
|
||||||
|
|
||||||
|
batt = frsky.get_data(frsky.dataid_FUEL)
|
||||||
|
self.progress("Got batt (%s) mav=%s" % (str(batt), str(want_battery_remaining_pct)))
|
||||||
|
if batt is None:
|
||||||
|
continue
|
||||||
|
if batt == want_battery_remaining_pct:
|
||||||
|
have_battery = True
|
||||||
|
|
||||||
|
if have_alt and have_battery:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.drain_mav_unparsed()
|
||||||
|
|
||||||
def test_ltm_g(self, ltm):
|
def test_ltm_g(self, ltm):
|
||||||
g = ltm.g()
|
g = ltm.g()
|
||||||
if g is None:
|
if g is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user