Skip to content

Commit

Permalink
autotest: added non-compass takeoff test
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Nov 25, 2024
1 parent 150afa4 commit 640f205
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Tools/autotest/arduplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import math
import os
import signal
import copy

from pymavlink import quaternion
from pymavlink import mavutil
Expand Down Expand Up @@ -4804,6 +4805,40 @@ def TakeoffTakeoff4(self):

self.fly_home_land_and_disarm()

def TakeoffTakeoff5(self):
'''Test the behaviour of a takeoff with no compass'''
self.set_parameters({
"COMPASS_USE": 0,
"COMPASS_USE2": 0,
"COMPASS_USE3": 0,
})
start_loc = copy.copy(SITL_START_LOCATION)
start_loc.heading = 175
self.customise_SITL_commandline(["--home=%.9f,%.9f,%.2f,%.1f" % (
start_loc.lat, start_loc.lng, start_loc.alt, start_loc.heading)])
self.reboot_sitl()
self.change_mode("TAKEOFF")

# waiting for the EKF to be happy won't work
self.delay_sim_time(20)
self.arm_vehicle()

target_alt = self.get_parameter("TKOFF_ALT")
self.wait_altitude(target_alt-5, target_alt, relative=True)

# Wait a bit for the Takeoff altitude to settle.
self.delay_sim_time(5)

bearing_margin = 35
loc = self.mav.location()
bearing_from_home = self.get_bearing(start_loc, loc)
if bearing_from_home < 0:
bearing_from_home += 360
if abs(bearing_from_home - start_loc.heading) > bearing_margin:
raise NotAchievedException(f"Did not takeoff in the right direction {bearing_from_home}")

self.fly_home_land_and_disarm()

def TakeoffGround(self):
'''Test a rolling TAKEOFF.'''

Expand Down Expand Up @@ -6416,6 +6451,7 @@ def tests1b(self):
self.TakeoffTakeoff2,
self.TakeoffTakeoff3,
self.TakeoffTakeoff4,
self.TakeoffTakeoff5,
self.TakeoffGround,
self.TakeoffIdleThrottle,
self.ForcedDCM,
Expand Down

0 comments on commit 640f205

Please sign in to comment.