This application will help us to understand how to connect to Tello and also to start to interact with this drone.
// Import the libraries
from time import sleep
import tellopy
// Define the handler of de drone, to detect when we have a flight event.
def handler(event, sender, data, **args):
drone = sender
if event is drone.EVENT_FLIGHT_DATA:
print(data)
// Define our function that would help us to create our rutine,
// First we subscribe to the handler, and then we connect to the drone.
// We need to wait for a connection and if not this would fail.
// We give the insturction of takeoff and land.
def test():
drone = tellopy.Tello()
try:
drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
drone.connect()
drone.wait_for_connection(60.0)
drone.takeoff()
sleep(5)
drone.land()
sleep(5)
except Exception as ex:
print(ex)
finally:
drone.quit()
if __name__ == '__main__':
test()