Connecting to Tello Drone through WSL

564 views Asked by At

I am trying to connect and control a Tello drone from Ubuntu 18.04 using WSL but having trouble with the networking part. I am building off of the dji-sdk/Tello-Python/Tello_Video python code available on GitHub which I've been able to use successfully on native Ubuntu.

Through Windows networking I am connected to the Drone's WiFi network but I'm not sure how to configure WSL or what to pass into the Tello class constructor to get things to connect.

For reference, normally I am able to connect to the Drone with the simple snippet below:

from tello import Tello
tello_obj = Tello('', 8889)  

The full constructor header for the Tello class is given as:

def __init__(self, local_ip, local_port, imperial=False, command_timeout=.3, tello_ip='192.168.10.1', tello_port=8889)

So I'm pretty sure I just need to pass the right IP/ports but not sure where I should find this. Thanks for any help!

1

There are 1 answers

0
Keshav.h On

This might not be the best answer, but maybe try the port 8890. if that does not work, you can try an alternative .. the djitellopy library or the tellopy library. I would suggest the tellopy library available on github. but if you also wanna try the djitellopy, more for users than debuggers/programmers then you can, no problem.

tellopy: https://github.com/hanyazou/TelloPy

djitellopy: https://github.com/damiafuentes/DJITelloPy

if you're gonna try tellopy, here is an example code:

from time import sleep
import tellopy


def handler(event, sender, data, **args):
    drone = sender
    if event is drone.EVENT_FLIGHT_DATA:
        print(data)


def test():
    drone = tellopy.Tello()
    try:
        drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
        drone.connect()
        drone.wait_for_connection(60.0)
        drone.takeoff()
        sleep(5)
        drone.down(50)
        sleep(5)
        drone.land()
        sleep(5)
    except Exception as ex:
        print(ex)
    finally:
        drone.quit()

if __name__ == '__main__':
    test()

if you're doing djitellopy, then this is the same code but simplified:

from djitellopy import tello
from time import sleep

drone = tello.Tello()
drone.connect()
print(drone.get_battery())  # optional

def doSomething():
    drone.takeoff()
    sleep(1)
    drone.rotate_clockwise(90)
    sleep(1)
    drone.land()
    sleep(1)

condition = 1 > 0

if (condition):  # optional
    doSomething()

tested everything on windows.

personally, I work more with djitellopy because it has easier stream handeling than tellopy.

I really hope everything works for you. goodluck!