Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Python interface

Hello,

I tried your "tardis" script but I had to tweak things a little bit. My guess is that you use python 2 on linux, and I use python 3 on windows. I had to modify the syntax (basically add some '(' and ')' in some functions and also install a windows version of the curses library.
As I am not a code expert I was pretty proud of myself when I first saw the screen appearing with the list of commands and the history fields. Unfortunately commands didn't work and did not append the history list.
My guess is that I have a syntax error (even without error messages) and something should be modified in the script to use with py3, maybe in the "response=drone.command(param)"
or in the wrapper command at the end of the script.
Again, my knowledge of python is limited and old...

I'll retry because it is fun.

Hugh

Exactly right, Linux and Python 2.7. I'll try downloading Python 3 on Windows and see what's happening when I have a chance - sounds like you have a good start on getting it to work. It's always fun to tinker . . . hack away!
 
Finally made it, after few hours of tweaking and basically destroying the tardis.py script with debugging flags everywhere I realized that i was facing the string (str) interpretation differences between Py2 and Py3.
In Py3, the input command does not send a string, but a 'byte' type object. So I had to place a few .decode('utf-8') after some variables to make it work.
Looks like I'm now ready to pilot my own blue vintage police box :)
 
Finally made it, after few hours of tweaking and basically destroying the tardis.py script with debugging flags everywhere I realized that i was facing the string (str) interpretation differences between Py2 and Py3.

Awesome, great work! That does ring a bell, I seem to recall one of the big differences between 2 and 3 was string handling. I should probably start considering compatibility with 3, I've always worked in environments with 2.
 
  • Like
Reactions: Hugh
Hello, great project.
Hugh. I am interested in the project for Phyton 3, it is possible to obtain the modified code.
Thank you.
 
The following week I will have the Tello with two batteries.
My intention is to make flight routes with Py3.

Regards.
 
There's a Tello3.py script in the SDK package.
I have Python 3.5 .2 installed on Windows 10.
I connect my PC to the Tello wifi.
If from command line I type "py Tello3.py" I get this

Tello Python3 Demo.

Tello: command takeoff land flip forward back left right
up down cw ccw speed speed?


end -- quit demo.

but typing takeoff and nothing happens.
Is this how to demonstrate the command interface? And if so, what might be wrong?
 
another question, does Tello only reply on the UDP port 9000 if using the command interface?

I'm not exactly sure what you are asking, but it will reply from UDP 8889 to whichever IP/port you initiated 'command' mode from. If that's not what you are asking, could you provide some context?
 
I notice that the tello3.py script opens a port at 9000 to get the responses from the Tello, but then I've seen another script that uses port 8888 to listen. Are these port numbers fixed?
 
I notice that the tello3.py script opens a port at 9000 to get the responses from the Tello, but then I've seen another script that uses port 8888 to listen. Are these port numbers fixed?

The port the Tello responds to is arbitrary - whatever is set in the UDP headers. In the case of Python, socket.bind will set this. You can bind to any port you have have permissions for.
 
Hello, great project.
Hugh. I am interested in the project for Phyton 3, it is possible to obtain the modified code.
Thank you.
Hello Tincdron.
To have the Microlinux Py scripts (tello.py and tardis.py) to work on Py3/Win10 you must first install a windows python "curses" library. I installed this one: curses-2.2-cp36-cp36m-win_amd64.whl from this site (https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses)
Then the 2 attached scripts should work.
 

Attachments

  • tello.zip
    4.6 KB · Views: 44
The port the Tello responds to is arbitrary - whatever is set in the UDP headers. In the case of Python, socket.bind will set this. You can bind to any port you have have permissions for.

In the tello3.py demo script I changed the port number to 9001, and also tried 8887

Code:
host = ''
port = 9000
locaddr = (host,port)

# Create a UDP socketsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
tello_address = ('192.168.10.1', 8889)

sock.bind(locaddr)

and it stopped working. So, I was thinking it only works for ports 1 up or down from the control port. But admittedly I didn't test other ports.
 
Hello Tincdron.
To have the Microlinux Py scripts (tello.py and tardis.py) to work on Py3/Win10 you must first install a windows python "curses" library. I installed this one: curses-2.2-cp36-cp36m-win_amd64.whl from this site (https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses)
Then the 2 attached scripts should work.


Hello Hugh,
Thank you very much, to see if Tello arrives and I start to try the scripts.
I will keep you informed, I find this topic very interesting.
I want to test it from android with Py3.

Regards.
 
The port the Tello responds to is arbitrary - whatever is set in the UDP headers. In the case of Python, socket.bind will set this. You can bind to any port you have have permissions for.

I think I see what's happening. Tello will respond to any port but then keeps that port number remembered while it's powered up. So, I connected to Tello from a 54,000 port number, and then tried the sample tello3.py script and it was unable to connect.

So, I guess that's why the demo tello3.py script binds to a specific port as it knows it must use the same number until it's cold reset.
 
Hi Guys, experienced PHP programmer here who is new to Python, I have a couple of questions, when initialising the tello class am I correct in using my local ip address and "ANY" unused port? I have used....

drone = Tello('192.168.0.13', 2178)
drone.takeoff()
time.sleep(15)
drone.land()

and this is my error, forgive me, new to python, please advise...

1525192244347.png
 
Hi Guys, experienced PHP programmer here who is new to Python, I have a couple of questions, when initialising the tello class am I correct in using my local ip address and "ANY" unused port? I have used....

drone = Tello('192.168.0.13', 2178)
drone.takeoff()
time.sleep(15)
drone.land()

and this is my error, forgive me, new to python, please advise...

View attachment 287

You have to use the tello address and you must be connected to the tello as well.

tello_address = (‘192.168.10.1, 8889)
 
Last edited:

New Posts

Members online

No members online now.

Forum statistics

Threads
5,701
Messages
39,968
Members
17,066
Latest member
alqar

New Posts