Here is the video from the DroneBlocks webinar hosted by Clinton Evans:
The code from the webinar can be found below:
# Import required Libraries
from droneblocks.DroneBlocksTello import DroneBlocksTello
import time
# Start the Tello instance
tello = DroneBlocksTello()
# Join RMTT Wifi first
# Once you have connected to the Tello Wifi then run tello.connect()
tello.connect()
# Find out the battery life
tello.get_battery()
# Some Tello movements below, remove the # if you want to use the code
# tello.takeoff()
# tello.fly_forward(100)
# tello.rotate_clockwise(90)
# tello.fly_backward(100)
# tello.rotate_counter_clockwise(90)
# Running this function returns the battery value
def BatReport():
return tello.get_battery()
# If statement to see if we can fly if battery is above 50%
if BatReport() > 50:
print("Let's fly!!")
print(BatReport())
# Create flight check function. Let's do some fancy inline comments
def PreFlightCheck(): # name function
if tello.get_battery() > 30: # if battery life is higher than 30
print("Drone's Up! " + str(tello.get_battery()) + "% Battery Left") # print message + battery life %
else: # else do the following
print("Not enough power captain") # print message saying not enough power
# Create mission to fly in a square
def SquareMission():
tello.takeoff()
for i in range(4):
time.sleep(3)
tello.move_forward(100)
time.sleep(3)
tello.rotate_clockwise(90)
tello.land()
# Create function that asks if it is safe to fly
def SafeToFly():
ans = input("Is it safe to fly? ").lower() # this makes the typed answer lower case and easier to compare
if ans == "yes": # if yes == yes then print success message and take off
print("Awesome! Drones Up!")
tello.takeoff()
else:
print("Well maybe next time")
tello.land()
Here you can find the DroneBlocksPythonUtils pip package that will enable you to run the code above and do a lot of cool stuff covered in many of these courses.
If you’d like to give the DroneBlocks Python Simulator a try, please go here and read through the instructions. If you have any problems don’t hesitate to post a question and we’ll be happy to respond.
Lastly, you can learn about OpenCV with Tello from Pat Ryan by checking out this course.