From 0f913b5bdfde2759ecc40011279683325332116d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 11 Apr 2024 15:27:50 +1000 Subject: [PATCH] autotest: add test altitudes in camera log messages are correct --- Tools/autotest/arducopter.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index f561cf8ce8..9b47f12106 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -10783,6 +10783,51 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): self.wait_disarmed() + def CameraLogMessages(self): + '''ensure Camera log messages are good''' + self.set_parameter("RC12_OPTION", 9) # CameraTrigger + self.set_parameter("CAM1_TYPE", 1) # Camera with servo trigger + self.reboot_sitl() # needed for RC12_OPTION to take effect + + gpis = [] + gps_raws = [] + + self.takeoff(10, mode='GUIDED') + self.set_rc(12, 2000) + gpis.append(self.assert_receive_message('GLOBAL_POSITION_INT')) + gps_raws.append(self.assert_receive_message('GPS_RAW_INT')) + self.set_rc(12, 1000) + + self.fly_guided_move_local(0, 0, 20) + + self.set_rc(12, 2000) + gpis.append(self.assert_receive_message('GLOBAL_POSITION_INT')) + gps_raws.append(self.assert_receive_message('GPS_RAW_INT')) + self.set_rc(12, 1000) + + dfreader = self.dfreader_for_current_onboard_log() + self.do_RTL() + + for i in range(len(gpis)): + gpi = gpis[i] + gps_raw = gps_raws[i] + m = dfreader.recv_match(type="CAM") + + things = [ + ["absalt", gpi.alt*0.001, m.Alt], + ["relalt", gpi.relative_alt*0.001, m.RelAlt], + ["gpsalt", gps_raw.alt*0.001, m.GPSAlt], # use GPS_RAW here? + ] + for (name, want, got) in things: + if abs(got - want) > 1: + raise NotAchievedException(f"Incorrect {name} {want=} {got=}") + self.progress(f"{name} {want=} {got=}") + + want = gpi.relative_alt*0.001 + got = m.RelAlt + if abs(got - want) > 1: + raise NotAchievedException(f"Incorrect relalt {want=} {got=}") + def tests2b(self): # this block currently around 9.5mins here '''return list of all tests''' ret = ([ @@ -10860,6 +10905,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): self.Ch6TuningWPSpeed, self.PILOT_THR_BHV, self.GPSForYawCompassLearn, + self.CameraLogMessages, ]) return ret