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

Do i need to send 'command' to tello every time i send another command?

vasilis1926

New member
Joined
Feb 7, 2020
Messages
4
Reaction score
0
I am new in tello and in python also.

I am trying to programm a software to command and fly tello over my computer.
I send 'command' over the socket when i inititalize the tello.py and then i dont send it any more. The dronne only takes of and lands when i press the button i programmed. But i think the dronne dosnt listen to the othe commands for moving it as it should.
I am wandering if i have to send allways the command 'command' before i send anything else for ex. like 'up x'

Here is the code:
>> tello.py

class Tello:
localIP = ''"
localPort = 8890
local_video_port = 11111
localAddr = (localIP, localPort)
telloIP = '192.168.10.1'
telloUDPPort = 8889
sock = None

def __init__(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.telloAddress = (self.telloIP, self.telloUDPPort)
self.sock.bind(self.localAddr)
self.telCommand()
logging.basicConfig(level=logging.INFO)

self.video_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.video_socket.bind((self.localIP, self.local_video_port))

loggingThread = threading.Thread(target=self.loging, args=())
loggingThread.daemon = True # Daemonize loggingThread
loggingThread.start() # Start the execution


def telCommand(self):
self.sock.sendto("command".encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello command")

# Takeoff
def telTakeoff(self):
self.sock.sendto("takeoff".encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello takeoff")

# Rotate clockwise
def telRotateCw(self, degrees):
self.sock.sendto(("cw %s" % degrees).encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello rotate cw %s" % degrees)

# Rotate reverse clockwise 360
def telRotateCcw(self, degrees):
self.sock.sendto(("ccw %s" % degrees).encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello rotate ccw %s" % degrees)

# Land
def telLand(self):
self.sock.sendto("land".encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello land")

# streamon
def telStreamon(self):
self.sock.sendto("streamon".encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello streamon")

# streamoff
def telStreamoff(self):
self.sock.sendto("streamoff".encode(encoding="utf-8"), self.telloAddress)
print("[tello] tello streamoff")

.
.
.

>> ui_control.py

...
...

class Form(QWidget):

def __init__(self, parent=None):
super(Form, self).__init__(parent)

# controlling vars
self.distance = 5
self.degree = 30
self.stream = 0

self.drone = Tello()



.
.
.


def keyPressEvent(self, event):
key = event.key()
if key == Qt.Key_W:
self.drone.telMove(direction=dir.UP, distance=self.distance)

if key == Qt.Key_S:
self.drone.telMove(direction=dir.DOWN, distance=self.distance)

if key == Qt.Key_A:
self.drone.telRotateCcw(self.degree)

if key == Qt.Key_D:
self.drone.telRotateCw(self.degree)

if key == Qt.Key_Space:
self.drone.telLand()

if key == Qt.Key_Escape:
self.drone.telEmergency()

if key == Qt.Key_Return:
self.drone.telTakeoff()

if key == Qt.Key_Up:
self.drone.telMove(direction=dir.FORWARD, distance=self.distance)

if key == Qt.Key_Down:
self.drone.telMove(direction=dir.BACK, distance=self.distance)

if key == Qt.Key_Left:
self.drone.telMove(direction=dir.LEFT, distance=self.distance)

if key == Qt.Key_Right:
self.drone.telMove(direction=dir.RIGHT, distance=self.distance)
print('Key Press Event fired %s' % (event.key()))

def streamVideo(self):
if self.stream == 0:
self.drone.telStreamon()
print("[ui]streaming video..")
self.b_streamVideo.setText("stop streaming")
self.stream = 1
else:
self.drone.telStreamoff()
print("[ui]stop streaming")
self.b_streamVideo.setText("start streaming")
self.stream = 0


if __name__ == '__main__':
# Create the Qt Application
app = QApplication(sys.argv)
# Create and show the form
form = Form()
form.show()
# Run the main Qt loop
sys.exit(app.exec_())
 

vasilis1926

New member
Joined
Feb 7, 2020
Messages
4
Reaction score
0
No, once is enough. But you can send "command" any time, e.g. as a keep alive signal.
Thank you for your answer. Are you able to see in this posted code why my tello only follows the commands take off and land? The code looks somehow okay to me
 

vasilis1926

New member
Joined
Feb 7, 2020
Messages
4
Reaction score
0
Thank you for your answer. Are you able to see in this posted code why my tello only follows the commands take off and land? The code looks somehow okay to me
i solved it the problem was the """ direction=dir.DOWN """ it had to be """direction=dir.DOWN.value"""
 

martinpi

Well-known member
Joined
Dec 15, 2019
Messages
45
Reaction score
27
Location
Vienna. Austria
Website
martinpi.at
I tried to execute your code above.
When you copied it into the post, all the indentations were lost. And some quote marks and parentheses were lost also. So I ended up with almost as many errors as lines.
Just for my (and possibly other user's) curiosity, can you post your code again, using the "code"-tags? You can use the preview to see if it has worked.

this
is an
indented text

Code:
this
  is an
    indented text
 

New Threads

Members online

Forum statistics

Threads
4,072
Messages
30,957
Members
10,407
Latest member
Perun