Skip to content

Commit

Permalink
Tools: support MISSION_CHECKSUM message
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Jul 1, 2023
1 parent 1c14b6f commit 7598cda
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tools/autotest/ArduPlane_Tests/MissionOpaqueID/empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
QGC WPL 110
13 changes: 13 additions & 0 deletions Tools/autotest/ArduPlane_Tests/MissionOpaqueID/flaps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
QGC WPL 110
0 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363262 149.165237 584.390015 1
1 0 3 22 15.000000 0.000000 0.000000 0.000000 -35.361279 149.164230 30.000000 1
2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.361229 149.163025 80.000000 1
3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.364563 149.163773 80.000000 1
4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.364384 149.164795 80.000000 1
5 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.361027 149.164093 80.000000 1
6 0 0 177 2.000000 3.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1
7 0 3 189 0.000000 0.000000 0.000000 0.000000 -35.362915 149.162613 60.000000 1
8 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.363136 149.162750 60.000000 1
9 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.365467 149.164215 55.000000 1
10 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.365009 149.165482 39.889999 1
11 0 3 21 0.000000 0.000000 0.000000 1.000000 -35.363041 149.165222 0.000000 1
9 changes: 9 additions & 0 deletions Tools/autotest/ArduPlane_Tests/MissionOpaqueID/jumpcount.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
QGC WPL 110
0 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363262 149.165238 584.090027 1
1 0 3 22 15.000000 0.000000 0.000000 0.000000 -35.359833 149.164703 41.029999 1
2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.359585 149.161392 100.000000 1
3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.366463 149.162231 100.000000 1
4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.366131 149.164581 100.000000 1
5 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.359272 149.163757 100.000000 1
6 0 0 177 2.000000 2.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1
7 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.359272 149.163757 100.000000 1
2 changes: 2 additions & 0 deletions Tools/autotest/ArduPlane_Tests/MissionOpaqueID/justhome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
QGC WPL 110
0 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.362938 149.165085 650.000000 1
374 changes: 374 additions & 0 deletions Tools/autotest/ArduPlane_Tests/MissionOpaqueID/text.txt

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions Tools/autotest/arduplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -3676,6 +3676,48 @@ def attempt_fence_breached_disable(start_mode, end_mode, expected_mode, action):
attempt_fence_breached_disable(start_mode="FBWA", end_mode="FBWA", expected_mode="GUIDED", action=6)
attempt_fence_breached_disable(start_mode="FBWA", end_mode="FBWA", expected_mode="GUIDED", action=7)

def get_mission_checksum(self):
self.drain_mav()
m = self.poll_message('MISSION_CURRENT')
print("Got %s" % str(m))
return m.mission_id

def MissionOpaqueID(self):
'''test support for vehicle identifying mission via opaque ID'''
jumpcount_checksum = 2006072681
for missionstuff in [("text.txt", 4264322242),
("empty.txt", 4294967295),
("justhome.txt", 4294967295),
("jumpcount.txt", jumpcount_checksum),
]:
(filename, expected_checksum) = missionstuff
self.progress("Checking checksum for (%s)" % (filename,))
self.load_mission(filename)
self.assert_cached_message_field_values('MISSION_ACK', {
"opaque_id": expected_checksum,
})
# ensure it appears in the MISSION_CURRENT message:
self.assert_received_message_field_values('MISSION_CURRENT', {
"mission_id": expected_checksum,
}, poll=True)

# fly the jump count mission, make sure the checksum doesn't
# change over time
self.load_mission("jumpcount.txt", strict=False)
self.set_current_waypoint(0, check_afterwards=False)
self.change_mode('AUTO')
self.wait_ready_to_arm()
self.arm_vehicle()
for i in range(2):
self.wait_current_waypoint(2, timeout=120)
self.wait_current_waypoint(3, timeout=120)
mission_checksum = self.get_mission_checksum()
if mission_checksum != jumpcount_checksum:
raise NotAchievedException(
"Mission checksum changed during mission; got=%u want=%u i=%u" %
(jumpcount_checksum, mission_checksum, i))
self.fly_home_land_and_disarm()

def MAV_DO_AUX_FUNCTION(self):
'''Test triggering Auxiliary Functions via mavlink'''
self.context_collect('STATUSTEXT')
Expand Down Expand Up @@ -4676,6 +4718,7 @@ def tests(self):
self.MAVFTP,
self.AUTOTUNE,
self.MegaSquirt,
self.MissionOpaqueID,
self.MSP_DJI,
self.SpeedToFly,
self.GlideSlopeThresh,
Expand Down
12 changes: 12 additions & 0 deletions Tools/autotest/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4785,9 +4785,21 @@ def check_mission_item_upload_download(self, items, itype, mission_type, strict=
self.progress("check %s upload/download: upload %u items" %
(itype, len(items),))
self.upload_using_mission_protocol(mission_type, items)
upload_opaque_id = self.get_cached_message('MISSION_ACK').opaque_id
if upload_opaque_id == 0:
raise NotAchievedException("Expected non-zero upload opaque_id")
self.progress("Upload opaque_id=%s" % upload_opaque_id)
self.progress("check %s upload/download: download items" % itype)
downloaded_items = self.download_using_mission_protocol(mission_type)
self.progress("Downloaded items: (%s)" % str(downloaded_items))
download_opaque_id = self.get_cached_message('MISSION_COUNT').opaque_id
if download_opaque_id == 0:
raise NotAchievedException("Expected non-zero download opaque_id")
if upload_opaque_id != download_opaque_id:
raise NotAchievedException(
"Expected upload id and download id to be same; upload=%s download=%s" %
(upload_opaque_id, download_opaque_id))

if len(items) != len(downloaded_items):
raise NotAchievedException("Did not download same number of items as uploaded want=%u got=%u" %
(len(items), len(downloaded_items)))
Expand Down

0 comments on commit 7598cda

Please sign in to comment.