diff --git a/Python3/src/cognitiveModel.py b/Python3/src/cognitiveModel.py index 57ef097..fb2ab4c 100644 --- a/Python3/src/cognitiveModel.py +++ b/Python3/src/cognitiveModel.py @@ -388,7 +388,6 @@ class AircraftLandingModel(pyactr.ACTRModel): # Send all controls simultaneously to X-Plane self.send_controls_to_xplane(yoke_pull, yoke_steer+additive, rudder, throttle) - def send_controls_to_xplane(self, yoke_pull, yoke_steer, rudder, throttle): """ Sends all control inputs to X-Plane using XPlaneConnect diff --git a/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.mp3 b/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.mp3 new file mode 100644 index 0000000..57c8abd Binary files /dev/null and b/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.mp3 differ diff --git a/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav b/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav new file mode 100644 index 0000000..ccc0f4c Binary files /dev/null and b/Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav differ diff --git a/Python3/src/experiments/weather_files/weather.csv b/Python3/src/experiments/weather_files/weather.csv index 5c96b08..963773b 100644 --- a/Python3/src/experiments/weather_files/weather.csv +++ b/Python3/src/experiments/weather_files/weather.csv @@ -1,8 +1,28 @@ -Experiment Number,Starting Altitude (AGL),Wind Layer Altitude,Wind Direction,Wind Speed -1,2000,0,179,0 -2,2000,0,179,5 -3,2000,0,179,10 -4,2000,0,179,15 -5,2000,0,179,20 -6,2000,0,179,25 -7,2000,0,179,30 \ No newline at end of file +Wind Experiments,Starting Altitude (AGL),Wind Layer Altitude,Wind Direction,Wind Speed,Direction Offset(Setup Only),Main Heading +1,2000,0,139,5,-40,179 +2,2000,0,149,5,-30, +3,2000,0,159,5,-20, +4,2000,0,169,5,-10, +5,2000,0,179,5,0, +6,2000,0,189,5,10, +7,2000,0,199,5,20, +8,2000,0,209,5,30, +9,2000,0,219,5,40, +10,2000,0,139,10,-40, +11,2000,0,149,10,-30, +12,2000,0,159,10,-20, +13,2000,0,169,10,-10, +14,2000,0,179,10,0, +15,2000,0,189,10,10, +16,2000,0,199,10,20, +17,2000,0,209,10,30, +18,2000,0,219,10,40, +19,2000,0,139,15,-40, +20,2000,0,149,15,-30, +21,2000,0,159,15,-20, +22,2000,0,169,15,-10, +23,2000,0,179,15,0, +24,2000,0,189,15,10, +25,2000,0,199,15,20, +26,2000,0,209,15,30, +27,2000,0,219,15,40, \ No newline at end of file diff --git a/Python3/src/testPlatform.py b/Python3/src/testPlatform.py index 59025a6..b55fc93 100644 --- a/Python3/src/testPlatform.py +++ b/Python3/src/testPlatform.py @@ -1,5 +1,3 @@ - - import datetime from math import cos, pi, sin, sqrt import os @@ -10,6 +8,12 @@ from cognitiveModel import AircraftLandingModel import shutil import csv from enum import Enum +from playsound import playsound +import threading as threading + +# import pyautogui as pag + + class messageType(Enum): @@ -150,7 +154,13 @@ def experimentSetUp(client,currentConditions,newExperiment): else: print("Experiment currently in progress, not resetting position and environmental conditions") -def runExperiment(title,currentConditions,allowPrinting,isNewExperiment): +def printLoop(status,data): + while(status): + print(str(data)) + if(not status): + print("Thread Should Finish Now") + +def runExperiment(title,currentConditions,allowPrinting,isNewExperiment,experimentCount): specialPrint("New Experiment\nSetting Up the Simulation",False,messageType.REGULAR) startTime = 0 endTime = 0 @@ -160,7 +170,7 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment): newExperiment = isNewExperiment while(timeElapsed <= timeoutLimit and experimentInProgress): - # print("Time Elapsed: -----> " + str(timeElapsed)) + try: with xpc.XPlaneConnect() as client: """ @@ -180,14 +190,21 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment): cogModel.client.pauseSim(False) newExperiment = False + + """ + SETUP DATA THREAD + """ + # thread = threading.Thread(target=printLoop(cogModel.getSimulationStatus(),cogModel.destinations.get("airspeed"))) + # thread.start() """ Single Experiment Loop """ + file = open("/Users/flyingtopher/X-Plane 11/Data.txt") while(experimentInProgress): cogModel.update_aircraft_state() cogModel.update_controls_simultaneously() client.pauseSim(False) #Unpause Simulator - sleep(0.05) # Let Simulator Run 50 Milliseconds + sleep(2) # Let Simulator Run 50 Milliseconds startTime = time.time() experimentInProgress = cogModel.getSimulationStatus() except: @@ -210,28 +227,45 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment): """ Ask Experimenter if they would like to exit experiment battery early """ - exitDecision = input("Press 'y' or any key to continue, press 'n' to exit...") + # exitDecision = input("Press 'y' or any key to continue, press 'n' to exit...") + exitDecision = "yes" + if(exitDecision == "n"): exitExperimentLoop = True else: exitExperimentLoop = False return exitExperimentLoop + +def say(msg = "Finish", voice = "Victoria"): + os.system(f'say -v {voice} {"Hello"}') + +# def playSound(): +# # wave_obj = sa.WaveObject.from_wave_file("Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav") +# # wave_obj.play() +# # # play_obj.wait_done() +# # song = AudioSegment.from_wav("Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav") +# # play(song) +# # playsound('Python3/src/experiments/terrain-terrain,-pull-up!-pull-up!-made-with-Voicemod.wav') + + + def setUp(): open("/Users/flyingtopher/X-Plane 11/Data.txt", 'w') specialPrint("Data Collection File Ready",False,messageType.REGULAR) -def cleanUp(title): +def cleanUp(count,title): now = datetime.datetime - shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/" + title + "_" + str(now.now()) + "_" + ".txt") + # shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/" + title + "_"+ count + "_" + str(now.now()) + "_" + ".txt") + shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/" + title + "_"+ str(count) + "_" + ".txt") print("CLEAN UP: Data File Deleted and Reset") - specialPrint("Data File Ready",False,messageType.REGULAR) def specialPrint(text, inputRequested,type): if(type == messageType.REGULAR): print("-" * 81) - print(text) + print('====> ', end='') + print(text, end= " <====\n") print("-" * 81 + "\n") if(inputRequested): inputReceived = input() @@ -242,26 +276,32 @@ def specialPrint(text, inputRequested,type): print("*" * 81 + "\n") + def ex(): + # playSound() """ One Time experimental setup """ - title = specialPrint("Please Enter Experiment Set Title, leave blank for trial runs\n", True, messageType.REGULAR) + title = specialPrint("Please Enter Experiment Set Title, leave blank for trial runs", False, messageType.REGULAR) + startAt = input("Start At Experiment #") experimentConditionMatrix = loadFile() - allowPrinting = True + title = str(experimentConditionMatrix[0][0]) + specialPrint("Title is: " + title, False, messageType.REGULAR) + allowPrinting = False isNewExperiment = True - experimentCount = 0 + experimentCount = int(startAt) """ Experiment Loop """ while(experimentCount