Skip to content

Commit ca52d8d

Browse files
committed
Reset mission on takeoff
1 parent e273cd3 commit ca52d8d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name='MAVez'
7-
version='3.2.0'
7+
version='3.2.1'
88
description='An intuitive MAVLink library for ArduPilot via pymavlink'
99
authors=[
1010
{name='The Pennsylvania State University Unmanned Aerial Systems Club', email='psuuasofficial@gmail.com'}

src/MAVez/controller.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,13 @@ async def receive_landing_status(self, timeout=TIMEOUT_DURATION) -> int:
710710
self.logger.error("[Controller] Bad response received for landing status")
711711
return self.BAD_RESPONSE_ERROR
712712

713-
async def set_message_interval(self, message_type, interval) -> int:
713+
async def set_message_interval(self, message_type: int, interval: int) -> int:
714714
"""
715715
Set the message interval for the specified message type.
716716
717717
Args:
718-
message_type (str): The type of message to set the interval for.
719-
interval (int): The interval in milliseconds to set for the message type.
718+
message_type (int): The type of message to set the interval for.
719+
interval (int): The interval in microseconds to set for the message type.
720720
timeout (int): The timeout duration in seconds. Default is 5 seconds.
721721
722722
Returns:
@@ -816,7 +816,7 @@ async def receive_current_mission_index(self) -> int:
816816
self.logger.error("[Controller] Bad response received for mission item reached")
817817
return self.BAD_RESPONSE_ERROR
818818

819-
async def set_current_mission_index(self, index) -> int:
819+
async def set_current_mission_index(self, index: int, reset: bool = False) -> int:
820820
"""
821821
sets the target mission index to the specified index
822822
@@ -833,7 +833,7 @@ async def set_current_mission_index(self, index) -> int:
833833
mavutil.mavlink.MAV_CMD_DO_SET_MISSION_CURRENT, # command
834834
0, # confirmation
835835
index, # param1
836-
0, # param2
836+
1 if reset else 0, # param2
837837
0, # param3
838838
0, # param4
839839
0, # param5

src/MAVez/flight_controller.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ async def takeoff(self, takeoff_mission_filename: str) -> int:
105105
self.logger.critical("[Flight] Takeoff failed, mission not sent")
106106
return response
107107

108-
# wait for mission to be fully received
109-
# Countdown from 5
110-
self.logger.info("[Flight] Takeoff in 5 seconds")
111-
for _ in range(5, 0, -1):
112-
time.sleep(1)
113-
114108
# set the mode to AUTO
115109
response = await self.set_mode("AUTO")
116110

117111
# verify that the mode was set successfully
118112
if response:
119113
self.logger.critical("[Flight] Takeoff failed, mode not set to AUTO")
120114
return response
115+
116+
# reset mission index to 0
117+
response = await self.set_current_mission_index(0, reset=True)
118+
if response:
119+
self.logger.critical("[Flight] Takeoff failed, could not reset mission index")
120+
return response
121121

122122
# arm ardupilot
123123
response = await self.arm()
@@ -244,7 +244,7 @@ async def wait_for_landing(self, timeout=60) -> int:
244244

245245
# start receiving landing status
246246
response = await self.set_message_interval(
247-
message_type=245, interval=1e6
247+
message_type=245, interval=100000
248248
) # 245 is landing status (EXTENDED_SYS_STATE), 1e6 is 1 second
249249
if response:
250250
self.logger.critical("[Flight] Failed waiting for landing.")

0 commit comments

Comments
 (0)