diff --git a/mavlink/modules/flight_controller.py b/mavlink/modules/flight_controller.py index c177c22..780630a 100644 --- a/mavlink/modules/flight_controller.py +++ b/mavlink/modules/flight_controller.py @@ -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