Skip to content

Commit

Permalink
added function to change drone flight mode (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashum68 authored Jun 21, 2024
1 parent 8928bab commit cda9168
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mavlink/modules/flight_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,15 @@ def move_to_position(self, position: drone_odometry.DronePosition) -> bool:
except dronekit.APIException as e:
print(f"ERROR in move_to_position() method: {e}")
return False

def set_flight_mode(self, mode: str) -> bool:
"""
Changes the flight mode of the drone.
https://ardupilot.org/copter/docs/flight-modes.html
"""
try:
self.drone.mode = dronekit.VehicleMode(mode)
except KeyError:
print("ERROR: an unsupported flight mode is set by dronekit.VehicleMode()")
return False
return True

0 comments on commit cda9168

Please sign in to comment.