def send_command(self, command: str, query: bool=False, make_photo: bool=False): # New log entry created for the outbound command self.log.append(Stats(command, len(self.log))) # Sending command to Tello self.socket.sendto(command.encode('utf-8'), self.tello_address) # Displaying conformation message (if 'debug' os True) if self.debug is True: print('Sending command: {}'.format(command)) # Checking whether the command has timed out or not (based on value in 'MAX_TIME_OUT') start = time.time() while not self.log[-1].got_response(): # Runs while no repsonse has been received in log now = time.time() difference = now - start if difference > self.MAX_TIME_OUT: print('Connection timed out!') break # Prints out Tello response (if 'debug' is True) if self.debug is True and query is False: print('Response: {}'.format(self.log[-1].get_response())) # At the end of each command, wait a little bit and take a photo # TODO: decide, whether time.sleep() is even necessary if make_photo: time.sleep(1) self.signal_to_make_photo()
def wait(self, delay: float): # Displaying wait message (if 'debug' is True) if self.debug is True: print('Waiting {} seconds...'.format(delay)) # Log entry for delay added self.log.append(Stats('wait', len(self.log))) # Delay is activated time.sleep(delay)
def send_command(self, command: str, query: bool =False): # New log entry created for the outbound command self.log.append(Stats(command, len(self.log))) # Sending command to Tello self.socket.sendto(command.encode('utf-8'), self.tello_address) # Displaying conformation message (if 'debug' os True) if self.debug is True: print('Sending command: {}'.format(command)) # Checking whether the command has timed out or not (based on value in 'MAX_TIME_OUT') start = time.time()
def send_command(self, command: str, query: bool = False): # New log entry created for the outbound command self.log.append(Stats(command, len(self.log))) # Sending command to Tello self.socket.sendto(command.encode('utf-8'), self.tello_address) # Displaying conformation message (if 'debug' os True) if self.debug is True: print('Sending command: {}'.format(command)) # Checking whether the command has timed out or not (based on value in 'MAX_TIME_OUT') start = time.time() while not self.log[-1].got_response( ): # Runs while no repsonse has been received in log now = time.time() difference = now - start if difference > self.MAX_TIME_OUT: print('Connection timed out!') break # Prints out Tello response (if 'debug' is True) if self.debug is True: if self.log[-1].got_response(): print('Response: {}'.format(self.log[-1].get_response()))
def send_command_no_response(self, command: str): # New log entry created for the outbound command self.log.append(Stats(command, len(self.log))) # Sending command to Tello self.socket.sendto(command.encode('utf-8'), self.tello_address)