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

Tello.py on Pythonista

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
I am trying to use microlinux/tello to talk to a Tello drone on Pythonista (ios app) but not getting too far.

After import tello, I try (in console):

drone = tello.Tello('192.168.10.2',8888)

drone = tello.Tello('192.168.10.2',8888)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/tello/tello.py", line 60, in __init__
raise RuntimeError('Tello rejected attempt to enter command mode')
RuntimeError: Tello rejected attempt to enter command mode
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
Are you sure 192.168.10.2 is the IP address of the device you're running that python script on?

To be sure your Tello works fine you could use the official Python script (https://dl-cdn.ryzerobotics.com/downloads/tello/20180222/Tello3.py). If it works the microlinux/tello is the problem. But if it doesn't work too there may be a problem with your Tello or with the connection to it.
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
The ios says the device address is 10.2 and the router is 10.1. The result of 192.168.10.2 at 8888 is as above. The result with 192.168.10.1 at 8889 is:

drone = tello.Tello('192.168.10.1',8889)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/tello/tello.py", line 52, in __init__
self.socket.bind((local_ip, local_port))
OSError: [Errno 49] Can't assign requested address
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
I tried Tello3.py as suggested by @an3k and it worked. At least it understood takeoff and landing so communication works. Not sure what the msg format should be to move forward, back, etc. but I presume that is documented somewhere (in the SDK?). I doubt that Pythonista can deal with the streaming video or photos but at least this is a step forward.
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
I'll try the microlinux/tello later when I'm at my notebook.

The commands and format possible with the Tello3.py are shown in the SDK PDF https://terra-1-g.djicdn.com/2d4dce68897a46b19fc717f3576b7c6a/Tello 编程相关/For Tello/Tello SDK Documentation EN_1.3_1122.pdf

It's basically up x, down x, forward x, right x, back x, left x (where x is in cm and within 20 - 500) or cw y, ccw y (where y is in degrees).

The PDF also tells you on how you can receive the video feed; but you have to develop the udp listener and a window to actually see it yourself.
 
Last edited:

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
Hmm...I tried command and the CODE you show but that gave no result. i must be getting the syntax wrong since takeoff and land work.
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
After takeoff what about these?
Code:
up 50
forward 100
cw 180
forward 100
down 50
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
hehe...won't takeoff now. I suspect the battery is too low. I finally managed to get it to take the battery? command and it said 8 so I am charging it and will report back.
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
Still trying to get microlinux/tello to work but I must have the addresses wrong as I continue to get the errors above. Can anyone get this script to work?
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
I tried it now and got the same results as you. I'm new to Python but did PHP and some Perl years ago. I was able to solve the problem.

Code:
C:\Users\Ben>python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tello
>>> import time
>>> drone = tello.Tello('192.168.10.2', 8888, imperial=False)
>>> drone.get_battery()
51
>>> drone.get_speed()
3.6
>>>
To get it working you have to modify the code of tello.py

Change line 59 from
if self.send_command('command') != 'OK':
to
if self.send_command('command') != 'ok':

Ignore how I got it working, I just used the exact example shown on the website. You don't have to import time to get it working, it's just changing line 59 that causes the problem :)
 
Last edited:

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
@an3k Thanks for finding that. I can now takeoff; however, I find that the drone will land itself after 10 seconds or so without any commands. Also, I have tried using other commands to move up,down, forward and backward and in general I get something like:
drone.move_up(2)​
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages-2/tello/tello.py", line 268, in move_up
return self.move('up', distance)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages-2/tello/tello.py", line 184, in move
return self.send_command('%s %s' % (direction, distance))
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages-2/tello/tello.py", line 296, in send_command
raise RuntimeError('No response to command')
RuntimeError: No response to command
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
I do get the same. Looks like the python script isn't perfectly working with the newer firmware versions anymore.

Code:
>>> drone.get_battery()
54
>>> drone.takeoff()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\lib\tello.py", line 349, in takeoff
    return self.send_command('takeoff')
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\lib\tello.py", line 296, in send_command
    raise RuntimeError('No response to command')
RuntimeError: No response to command
>>> drone.get_battery()
'ok'
>>> drone.get_battery()
54
>>> drone.get_battery()
54
>>> drone.land()
'54\r\n'
However, the drone was always responding to my commands, it was just the script not showing correct data.

I already published my bugfix to github and I noticed others have also published fixes and improvements to the code but since June the developer haven't made any changes so probably someone else has to Fork that project and implement all the improvements and fixes.
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
I do have the new firmware and the script undoubtedly needs to be updated. I like this script mostly because it runs under Pythonista on IOS and some other scripts I have seen have incompatible dependencies.
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
It is interesting how it will takeoff but then it spontaneously lands after 18 seconds. Is the firmware looking for something to show it is stilll being controlled?
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
I read somewhere that this is a normal behavior. If it doesn't receive commands within 15 seconds after takeoff it will land.
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
I think it may be what Ryze calls "failsafe protection". Given this feature, how does one write a python program that makes the drone hover in place for a period longer than 15s?
 

briest

Well-known member
Joined
Nov 21, 2018
Messages
96
Reaction score
55
Location
Silesia Superior
Maybe just keep asking for flight parameters, via "?" commands (get_... methods in tello.py)?
 

an3k

Active member
Joined
Dec 11, 2018
Messages
44
Reaction score
40
I think this failsafe is only active directly after takeoff. If you tell Tello to go up 50 and down 50 it hovers in the same position as directly after takeoff but does not land after 15 seconds again. This or what briest said :)
 

ihf

Well-known member
Joined
Nov 29, 2018
Messages
116
Reaction score
14
I just tested to see if that was true. After takeoff I had the drone move backward. It spontaneously landed after 15 s. (using tello.py on latest firmware)
 

New Threads

Members online

Forum statistics

Threads
3,222
Messages
24,932
Members
8,308
Latest member
johnnypurk