This scripts would help us to create a fly routine that we want that our drone reproduce. We can choose one of the three scripts each one have a different behavior.
This script would help us that drone rotate 180 degrees and then return to original position. Then drone would make a flip to the right and land.
Copy from time import sleep
import tellopy
def handler(event, sender, data, **args):
drone = sender
if event is drone.EVENT_FLIGHT_DATA:
print(data)
def tellofly():
drone = tellopy.Tello()
try:
drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
drone.connect()
drone.wait_for_connection(60.0)
drone.takeoff()
sleep(5)
drone.cw(180)
sleep(5)
drone.ccw(180)
sleep(5)
drone.flip(r)
sleep(5)
drone.land()
except Exception as ex:
print(ex)
finally:
drone.quit()
if __name__ == '__main__':
tellofly()
This script would make a routine and then land.
Copy from time import sleep
import tellopy
def handler(event, sender, data, **args):
drone = sender
if event is drone.EVENT_FLIGHT_DATA:
print(data)
def tellofly():
drone = tellopy.Tello()
try:
drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
drone.connect()
drone.wait_for_connection(60.0)
drone.takeoff()
sleep(5)
drone.go(20,20,20,20)
sleep(5)
drone.land()
except Exception as ex:
print(ex)
finally:
drone.quit()
if __name__ == '__main__':
tellofly()
This script would make that Drone Tello make a square and then land.
Copy from time import sleep
import tellopy
def handler(event, sender, data, **args):
drone = sender
if event is drone.EVENT_FLIGHT_DATA:
print(data)
def tellofly():
drone = tellopy.Tello()
try:
drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
drone.connect()
drone.wait_for_connection(60.0)
drone.takeoff()
sleep(5)
drone.forward(30)
sleep(5)
drone.right(30)
sleep(5)
drone.back(30)
sleep(5)
drone.left(30)
sleep(5)
drone.land()
except Exception as ex:
print(ex)
finally:
drone.quit()
if __name__ == '__main__':
tellofly()