Skip to content

Commit d4c7dfb

Browse files
committed
Tools: add ScriptingOSD autotest
Add autotest for OSD scripting functionality. The test: - Enables scripting and OSD - Installs the osd.lua example script - Uploads a simple waypoint mission - Flies the mission while the script displays waypoint info The test gracefully skips if SFML OSD is not available (requires SITL to be built with --enable-sfml --sitl-osd).
1 parent 95d6316 commit d4c7dfb

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Tools/autotest/arducopter.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14683,6 +14683,76 @@ def ScriptingFlyVelocity(self):
1468314683
# Test done
1468414684
self.land_and_disarm()
1468514685

14686+
def ScriptingOSD(self):
14687+
'''test OSD scripting with waypoint mission - requires SFML OSD'''
14688+
# This test requires SITL to be built with SFML support:
14689+
# ./waf configure --board sitl --enable-sfml --sitl-osd
14690+
# Without SFML, the OSD scripting bindings return nil and scripts fail.
14691+
14692+
# Check if OSD is compiled in by looking for OSD_TYPE parameter
14693+
try:
14694+
self.get_parameter("OSD_TYPE")
14695+
except Exception:
14696+
self.progress("OSD not compiled in, skipping test")
14697+
return
14698+
14699+
self.context_push()
14700+
self.context_collect('STATUSTEXT')
14701+
14702+
# Enable scripting and OSD
14703+
# Note: OSD_TYPE=3 is SITL OSD which requires --enable-sfml --sitl-osd
14704+
self.set_parameters({
14705+
"SCR_ENABLE": 1,
14706+
"OSD_TYPE": 3, # SITL OSD (requires SFML)
14707+
})
14708+
14709+
# Install the OSD example script
14710+
self.install_example_script_context('osd.lua')
14711+
self.reboot_sitl()
14712+
14713+
# Wait for script to start
14714+
self.delay_sim_time(3)
14715+
14716+
# Check if the script reports OSD is not available
14717+
# The script prints "osd not available" when no OSD backend is present
14718+
try:
14719+
self.wait_statustext("osd not available", timeout=5, check_context=True)
14720+
self.progress("OSD scripting not functional (SFML not enabled), skipping test")
14721+
self.context_pop()
14722+
return
14723+
except AutoTestTimeoutException:
14724+
# Good - no error message means OSD is working
14725+
pass
14726+
14727+
# Create a simple waypoint mission
14728+
# (type, north_offset_m, east_offset_m, alt_m)
14729+
items = [
14730+
(mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 0, 0, 20),
14731+
(mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 50, 0, 20), # 50m North
14732+
(mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 50, 50, 20), # 50m North, 50m East
14733+
(mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 50, 20), # 50m East
14734+
(mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 20), # Back to start
14735+
(mavutil.mavlink.MAV_CMD_NAV_LAND, 0, 0, 0),
14736+
]
14737+
14738+
# Set AUTO_OPTIONS to allow arming in AUTO mode
14739+
self.set_parameter("AUTO_OPTIONS", 3)
14740+
14741+
# Upload and start the mission
14742+
self.upload_simple_relhome_mission(items)
14743+
self.change_mode('AUTO')
14744+
self.wait_ready_to_arm()
14745+
self.arm_vehicle()
14746+
14747+
# Wait for mission to complete (land and disarm)
14748+
self.wait_disarmed(timeout=180)
14749+
14750+
# Verify no script errors occurred
14751+
# The script should have been running and displaying waypoint info
14752+
self.progress("OSD scripting mission test completed successfully")
14753+
14754+
self.context_pop()
14755+
1468614756
def RTLYaw(self):
1468714757
'''test that vehicle yaws to original heading on RTL'''
1468814758
# 0 is WP_YAW_BEHAVIOR_NONE
@@ -15794,6 +15864,7 @@ def tests2b(self): # this block currently around 9.5mins here
1579415864
self.TestTetherStuck,
1579515865
self.ScriptingFlipMode,
1579615866
self.ScriptingFlyVelocity,
15867+
self.ScriptingOSD,
1579715868
self.EK3_EXT_NAV_vel_without_vert,
1579815869
self.CompassLearnCopyFromEKF,
1579915870
self.AHRSAutoTrim,

0 commit comments

Comments
 (0)