Skip to content

Commit

Permalink
autotest: add QuadPlane.RealFlightTitanCobraHover
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 committed Oct 2, 2024
1 parent 17f956b commit 30f7c30
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Tools/autotest/autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ def run_step(step):
}
if opts.speedup is not None:
fly_opts["speedup"] = opts.speedup
if opts.realflight_address is not None:
fly_opts["realflight_address"] = opts.realflight_address

# handle "test.Copter" etc:
if step in tester_class_map:
Expand Down Expand Up @@ -1017,6 +1019,9 @@ def format_epilog(self, formatter):
group_sim.add_option("", "--replay",
action='store_true',
help="enable replay logging for tests")
group_sim.add_option("--realflight-address",
default=None,
help="IP address of RealFlight simulator")
parser.add_option_group(group_sim)

group_completion = optparse.OptionGroup(parser, "Completion helpers")
Expand Down
100 changes: 100 additions & 0 deletions Tools/autotest/default_params/realflight-titan-cobra.parm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Titan Cobra RealFlight ArduPilot 4.5
AHRS_EKF_TYPE,3
AIRSPEED_CRUISE,12.4
AIRSPEED_MAX,18
AIRSPEED_MIN,11
ARMING_RUDDER,2
ARSPD_OFFSET,2013
ARSPD_SKIP_CAL,1
ARSPD_USE,1
BATT_ARM_VOLT,14.7
BATT_CAPACITY,10800
BATT_CRT_VOLT,14
BATT_LOW_VOLT,14.4
FLIGHT_OPTIONS,1026
FLTMODE_CH,8
FLTMODE1,17
FLTMODE2,17
FLTMODE3,19
FLTMODE4,19
FLTMODE5,5
FLTMODE6,5
INS_GYRO_FILTER,36
NAVL1_PERIOD,9
PTCH_LIM_MIN_DEG,-14
PTCH_RATE_D,0.00903
PTCH_RATE_FF,1.042
PTCH_RATE_FLTD,18
PTCH_RATE_FLTT,2.122
PTCH_RATE_I,1.042
PTCH_RATE_P,0.806
PTCH_TRIM_DEG,4.2
PTCH2SRV_RMAX_DN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
TECS_RLL2THR,7
TECS_SINK_MAX,3
TECS_SINK_MIN,1.5
THROTTLE_NUDGE,0
TRIM_THROTTLE,47
WP_LOITER_RAD,70
WP_RADIUS,70
SIM_FTAX_OPTS,25
LOG_BITMASK,0x10FFFF
53 changes: 52 additions & 1 deletion Tools/autotest/quadplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,12 +703,21 @@ def default_mode(self):
return "MANUAL"

def disabled_tests(self):
return {
tests = {
"FRSkyPassThrough": "Currently failing",
"CPUFailsafe": "servo channel values not scaled like ArduPlane",
"GyroFFT": "flapping test",
"ConfigErrorLoop": "failing because RC values not settable",
}
for test in self.tests():
name = ""
if isinstance(test, Test):
name = test.name
else:
name = test.__name__
if name.lower().startswith("realflight"):
tests[name] = "needs RealFlight"
return tests

def BootInAUTO(self):
'''Test behaviour when booting in auto'''
Expand Down Expand Up @@ -1858,6 +1867,47 @@ def RTL_AUTOLAND_1_FROM_GUIDED(self):

self.fly_home_land_and_disarm()

def RealFlightTitanHover(self):
'''Test the RealFlight Titan Cobra'''
frame = "flightaxis"
if self.realflight_address is not None:
frame += f":{self.realflight_address}"
self.customise_SITL_commandline(
[
"--home", "40.0594626,-88.5513292,206.0,0",
"--wipe",
],
frame,
defaults_filepath="Tools/autotest/default_params/realflight-titan-cobra.parm"
)
self.set_rc(3, 1000)
self.wait_ready_to_arm()
self.change_mode("QLOITER")
self.arm_vehicle()
self.set_rc(3, 2000)
self.wait_altitude(8, 12, relative=True)
self.set_rc(3, 1500)
stick_deflections = [
(2000, 1500, "roll right"),
(1500, 1500, "center"),
(1000, 1500, "roll left"),
(1500, 1500, "center"),
(1500, 2000, "pitch forward"),
(1500, 1500, "center"),
(1500, 1000, "pitch back"),
(1500, 1500, "center"),
]
n_iterations = 10
for i in range(n_iterations):
print(f"Control input cycle: {i+1}/{n_iterations}")
for roll, pitch, msg in stick_deflections:
print(f"{msg}")
self.set_rc(1, roll)
self.set_rc(2, pitch)
self.delay_sim_time(0.5)
self.change_mode("QLAND")
self.wait_disarmed(timeout=120)

def tests(self):
'''return list of all tests'''

Expand Down Expand Up @@ -1906,5 +1956,6 @@ def tests(self):
self.DCMClimbRate,
self.RTL_AUTOLAND_1, # as in fly-home then go to landing sequence
self.RTL_AUTOLAND_1_FROM_GUIDED, # as in fly-home then go to landing sequence
self.RealFlightTitanHover,
])
return ret
2 changes: 2 additions & 0 deletions Tools/autotest/vehicle_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ def __init__(self,
dronecan_tests=False,
generate_junit=False,
enable_fgview=False,
realflight_address=None,
build_opts={}):

self.start_time = time.time()
Expand Down Expand Up @@ -1973,6 +1974,7 @@ def __init__(self,
self.in_drain_mav = False
self.tlog = None
self.enable_fgview = enable_fgview
self.realflight_address = realflight_address

self.rc_thread = None
self.rc_thread_should_quit = False
Expand Down

0 comments on commit 30f7c30

Please sign in to comment.