How To: Tello Drone To RoboRealm - Jack Pender, Blog #8
Introduction:
Python File:
·
The first step is to import all the libraries
that we will use.
·
We will be livestreaming the tello camera feed to
the localhost using flask, so we now initialize this flask app.
·
We also open up the connection to the drone; me
= Tello(), setting its name to “me”.
· We then create a function called “gen_frames” to continuously grab the image that the Tello camera is taking. These are essentially stitched together in order to create a video.
·
In “gen_frames”
we create a While loop, in which we get the frame from the Tello and
then flip it around so it isn’t mirrored.
· At the end of this While loop this flow of images is stitched together, resulting in the video that will be displayed in the localhost.
· Between the input of frames from Tello and their stitching together, there is code in order to detect the colour green. This isn’t absolutely necessary but could potentially be implemented to control the flight of the Tello drone.
· Lastly we deploy the flask application.
·
In order to get started with Tello and OpenCV I
found this video very useful:
Roborealm:
· Create a variable called "bootup" using Set_Variable like so.
·
Create a Button_Interface, with three buttons; reset,
takeoff and land
·
This is done by pressing config, where you can
assign each button a variable
·
To “reset” assign bootup as the variable, with a
value of 0
· You can now move the original Set_Variable to be after the Button_Interface
·
Now we can set up an If_Statement
·
Here, we set the variable as bootup, the Comparison
as “= equals”, Comparison Type as Integer and finally the Value as 0. We can
leave Join empty.
·
We can now set up a VBScript_Program in order to
run our python code.
· Select “Use The Following Text” and we can just write the Visual Basic code here.
Dim objShell, strPath1, strAttr1 ', strAttr2, strAttr3
Set objShell = CreateObject ("WScript.Shell")
strPath1 = """C:\Python\Python39\python.exe"""
strAttr1 = " droneColor.py "
objShell.Run strPath1 & strAttr1
·
We set two string to be printed out to the
terminal, leaving a space at the start of the second string so that it prints
as a legitimate command
·
We then use Set_Variable again to set bootup to
1, so that we don’t have an infinite loop
·
Now you can split your screen and, with
RoboRealm on the left and your browser on the right, opened on the “localhost/video_feed”
·
Using Screen_Capture we can record what is on
our screen
·
Select “Coordinates” to be the corners of the tello
video feed. Yours may be different to mine. You can also set the “Frequency” to
ASAP so that the video feed comes through in real time.
·
Finally, using Socket_Client we can connect to
the IP Address and Port that the Tello operates on and send it commands.
· Set “Server Address” to 192.168.10.1 and set “Server Port” to 8889. In the Console portion, select the “Ascii” option. In the box beneath “Ascii”, enter “command” and press Send Now. This is important as this establishes the UDP connection from RoboRealm to the Tello. Now you can send any of the Tello commands in order to control it e.g takeoff and land. This is a list of all the available commands: https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf
·
In order to get the livestream started, simply
send “streamon()”.
Comments
Post a Comment