From e3764d130e53ffaf7a9ef04dbe9725494de31a97 Mon Sep 17 00:00:00 2001 From: Jason D Date: Thu, 30 Oct 2025 12:05:14 -0500 Subject: [PATCH] Revert "Fixes Manual Drone Control crashing for linux." --- GUI5.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/GUI5.py b/GUI5.py index 94233168..91d9daf7 100644 --- a/GUI5.py +++ b/GUI5.py @@ -1,3 +1,20 @@ +""" +Avatar - BCI Application with NAO Robot Control +Author: Youssef Elkhouly +Date: October 2025 + +Description: + This module implements the backend for the Avatar BCI application, which integrates + brainwave reading, drone control, and NAO robot control. The application uses PySide6 + for the GUI framework and connects to various hardware controllers. + +Key Features: + - Brainwave data acquisition and processing + - Drone control via Tello SDK + - NAO robot connection and control with configurable IP/Port + - Machine learning predictions (Random Forest and Deep Learning) + - File shuffling and data transfer utilities +""" import sys import os @@ -8,7 +25,6 @@ from PySide6.QtCore import QObject, Signal, Slot, QProcess, QUrl from pdf2image import convert_from_path from djitellopy import Tello -import threading import random import re import pandas as pd @@ -201,7 +217,6 @@ def devChart(self): except Exception as e: print(f"hofCharts.main() ERROR: {e}") - #might be useless because is.connected is defined already in the def__init method def get_is_connected(self): return self.isConnectedChanged @@ -226,7 +241,6 @@ def __init__(self): self.is_connected = False try: self.tello = Tello() - self.connected = False except Exception as e: print(f"Warning: Failed to initialize Tello drone: {e}") self.logMessage.emit(f"Warning: Failed to initialize Tello drone: {e}") @@ -386,18 +400,19 @@ def keepDroneAlive(self): @Slot(str) def getDroneAction(self, action): - threading.Thread(target=self._doAction, args=(action,), daemon=True).start() - - def _doAction(self, action): - try: - if action == 'connect': + if action == 'connect': + try: self.tello.connect() - self.connected = True + self.is_connected = True self.logMessage.emit("Connected to Tello Drone") - elif self.connected: - self.logMessage.emit("Drone did not connect.") - return - + except: + self.is_connected = False + self.logMessage.emit("Error during connect: {e}") + return + elif not self.is_connected: + self.logMessage.emit(f"Drone not connected. Aborting command '{action}'.") + return + try: if action == 'up': self.tello.move_up(30) self.logMessage.emit("Moving up") @@ -421,7 +436,7 @@ def _doAction(self, action): self.logMessage.emit("Rotating left") elif action == 'turn_right': self.tello.rotate_clockwise(45) - self.logMessage.emit("Rotating right") + self.logMessage.emit("Rotationg right") elif action == 'takeoff': self.tello.takeoff() self.logMessage.emit("Taking off")