import time
from fly_tello import FlyTello

# Connect directly to a single Tello via its built-in Wi-Fi hotspot
with FlyTello([‘192.168.10.1’]) as fly:

# =========================================================================
# 1. TAKEOFF & LANDING
# =========================================================================
fly.takeoff() # Auto-takeoff and hover (~80 cm height)
time.sleep(3)

# =========================================================================
# 2. LINEAR MOVEMENTS (distance in cm: 20 to 500)
# =========================================================================
fly.up(dist=50) # Move straight up 50 cm
time.sleep(2)

fly.down(dist=30) # Move straight down 30 cm
time.sleep(2)

fly.forward(dist=60) # Move straight forward 60 cm
time.sleep(2)

fly.back(dist=60) # Move straight backward 60 cm
time.sleep(2)

fly.left(dist=50) # Move straight left 50 cm
time.sleep(2)

fly.right(dist=50) # Move straight right 50 cm
time.sleep(2)

# =========================================================================
# 3. ROTATIONS (angle in degrees: 1 to 360)
# =========================================================================
fly.rotate_cw(angle=90) # Spin clockwise 90 degrees
time.sleep(2)

fly.rotate_ccw(angle=90) # Spin counter-clockwise 90 degrees
time.sleep(2)

# =========================================================================
# 4. 3D COORDINATE & CURVED FLIGHT (x, y, z in cm; speed in cm/s: 10 to 100)
# =========================================================================
# Fly in a straight diagonal line to (x, y, z) relative to current position
fly.go(x=50, y=50, z=20, speed=40)
time.sleep(3)

# Fly a smooth arc passing through midpoint (x1, y1, z1) to endpoint (x2, y2, z2)
fly.curve(x1=40, y1=40, z1=0, x2=80, y2=0, z2=0, speed=35)
time.sleep(3)

# =========================================================================
# 5. ACROBATIC FLIPS (direction: ‘left’, ‘right’, ‘forward’, ‘back’)
# *Requires battery > 50%
# =========================================================================
fly.flip(direction=’forward’) # Perform a mid-air flip
time.sleep(3)

# =========================================================================
# 6. SPEED, SAFETY & UTILITY CONTROLS
# =========================================================================
fly.set_speed(speed=50) # Set default flight speed (10 to 100 cm/s)
time.sleep(1)

fly.stop() # Brake immediately and hover in place
time.sleep(2)

fly.land() # Gently descend and turn off motors

# EMERGENCY KILL-SWITCH (Uncomment only when needed – cuts motors instantly)
# fly.emergency() # Stops all propellers immediately (drone will drop)