How To: Tello Drone To RoboRealm - Jack Pender, Blog #8

 


Introduction:

This blog post is a tutorial intended to give you everything you need in order to start streaming the camera feed from a Tello drone and get this stream into RoboRealm. All of the necessary files are included in this repository: https://github.com/jackpender/TelloToRoboRealm
I have detailed the steps but I suggest also taking a look at the repository as you go, especially the python file if you aren't familiar with OpenCV.

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: https://www.youtube.com/watch?v=vDOkUHNdmKs

 

Roborealm:

·        Create a variable called "bootup" using Set_Variable like so.


·        Create a Display_Variables and have it display “bootup” in the top middle of the screen



·        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”

Yours won't livestream until all steps are complete so don't expect it to look like this


·        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

Popular posts from this blog

How to: Tello drone to micro bit - Victor Alikberov, Blog#1

First USV Test - Jack Pender, Blog #5

OpenCV To RoboRealm - Jack Pender, Blog #7