from dronekit import connect, VehicleMode vehicle = connect('udp:127.0.0.1:14550', wait_ready=True) # Set the mode to GUIDED vehicle.mode = VehicleMode("GUIDED")
if vehicle.mode.name == "AUTO": print("Drone is in AUTO mode.")
print("Current mode: %s" % vehicle.mode.name)In all these examples, we have used the DroneKit-Python library to connect to a drone and retrieve or set its flight mode using the VehicleMode class.