Pre-sleep() replacement in favor of a timer in order to customizs data logging
This commit is contained in:
@@ -388,7 +388,6 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# Send all controls simultaneously to X-Plane
|
# Send all controls simultaneously to X-Plane
|
||||||
self.send_controls_to_xplane(yoke_pull, yoke_steer+additive, rudder, throttle)
|
self.send_controls_to_xplane(yoke_pull, yoke_steer+additive, rudder, throttle)
|
||||||
|
|
||||||
|
|
||||||
def send_controls_to_xplane(self, yoke_pull, yoke_steer, rudder, throttle):
|
def send_controls_to_xplane(self, yoke_pull, yoke_steer, rudder, throttle):
|
||||||
"""
|
"""
|
||||||
Sends all control inputs to X-Plane using XPlaneConnect
|
Sends all control inputs to X-Plane using XPlaneConnect
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,28 @@
|
|||||||
Experiment Number,Starting Altitude (AGL),Wind Layer Altitude,Wind Direction,Wind Speed
|
Wind Experiments,Starting Altitude (AGL),Wind Layer Altitude,Wind Direction,Wind Speed,Direction Offset(Setup Only),Main Heading
|
||||||
1,2000,0,179,0
|
1,2000,0,139,5,-40,179
|
||||||
2,2000,0,179,5
|
2,2000,0,149,5,-30,
|
||||||
3,2000,0,179,10
|
3,2000,0,159,5,-20,
|
||||||
4,2000,0,179,15
|
4,2000,0,169,5,-10,
|
||||||
5,2000,0,179,20
|
5,2000,0,179,5,0,
|
||||||
6,2000,0,179,25
|
6,2000,0,189,5,10,
|
||||||
7,2000,0,179,30
|
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,
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from math import cos, pi, sin, sqrt
|
from math import cos, pi, sin, sqrt
|
||||||
import os
|
import os
|
||||||
@@ -10,6 +8,12 @@ from cognitiveModel import AircraftLandingModel
|
|||||||
import shutil
|
import shutil
|
||||||
import csv
|
import csv
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from playsound import playsound
|
||||||
|
import threading as threading
|
||||||
|
|
||||||
|
# import pyautogui as pag
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class messageType(Enum):
|
class messageType(Enum):
|
||||||
@@ -150,7 +154,13 @@ def experimentSetUp(client,currentConditions,newExperiment):
|
|||||||
else:
|
else:
|
||||||
print("Experiment currently in progress, not resetting position and environmental conditions")
|
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)
|
specialPrint("New Experiment\nSetting Up the Simulation",False,messageType.REGULAR)
|
||||||
startTime = 0
|
startTime = 0
|
||||||
endTime = 0
|
endTime = 0
|
||||||
@@ -160,7 +170,7 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment):
|
|||||||
newExperiment = isNewExperiment
|
newExperiment = isNewExperiment
|
||||||
|
|
||||||
while(timeElapsed <= timeoutLimit and experimentInProgress):
|
while(timeElapsed <= timeoutLimit and experimentInProgress):
|
||||||
# print("Time Elapsed: -----> " + str(timeElapsed))
|
|
||||||
try:
|
try:
|
||||||
with xpc.XPlaneConnect() as client:
|
with xpc.XPlaneConnect() as client:
|
||||||
"""
|
"""
|
||||||
@@ -180,14 +190,21 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment):
|
|||||||
cogModel.client.pauseSim(False)
|
cogModel.client.pauseSim(False)
|
||||||
newExperiment = False
|
newExperiment = False
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
SETUP DATA THREAD
|
||||||
|
"""
|
||||||
|
# thread = threading.Thread(target=printLoop(cogModel.getSimulationStatus(),cogModel.destinations.get("airspeed")))
|
||||||
|
# thread.start()
|
||||||
"""
|
"""
|
||||||
Single Experiment Loop
|
Single Experiment Loop
|
||||||
"""
|
"""
|
||||||
|
file = open("/Users/flyingtopher/X-Plane 11/Data.txt")
|
||||||
while(experimentInProgress):
|
while(experimentInProgress):
|
||||||
cogModel.update_aircraft_state()
|
cogModel.update_aircraft_state()
|
||||||
cogModel.update_controls_simultaneously()
|
cogModel.update_controls_simultaneously()
|
||||||
client.pauseSim(False) #Unpause Simulator
|
client.pauseSim(False) #Unpause Simulator
|
||||||
sleep(0.05) # Let Simulator Run 50 Milliseconds
|
sleep(2) # Let Simulator Run 50 Milliseconds
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
experimentInProgress = cogModel.getSimulationStatus()
|
experimentInProgress = cogModel.getSimulationStatus()
|
||||||
except:
|
except:
|
||||||
@@ -210,28 +227,45 @@ def runExperiment(title,currentConditions,allowPrinting,isNewExperiment):
|
|||||||
"""
|
"""
|
||||||
Ask Experimenter if they would like to exit experiment battery early
|
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"):
|
if(exitDecision == "n"):
|
||||||
exitExperimentLoop = True
|
exitExperimentLoop = True
|
||||||
else:
|
else:
|
||||||
exitExperimentLoop = False
|
exitExperimentLoop = False
|
||||||
return exitExperimentLoop
|
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():
|
def setUp():
|
||||||
open("/Users/flyingtopher/X-Plane 11/Data.txt", 'w')
|
open("/Users/flyingtopher/X-Plane 11/Data.txt", 'w')
|
||||||
specialPrint("Data Collection File Ready",False,messageType.REGULAR)
|
specialPrint("Data Collection File Ready",False,messageType.REGULAR)
|
||||||
|
|
||||||
def cleanUp(title):
|
def cleanUp(count,title):
|
||||||
now = datetime.datetime
|
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")
|
print("CLEAN UP: Data File Deleted and Reset")
|
||||||
|
|
||||||
specialPrint("Data File Ready",False,messageType.REGULAR)
|
specialPrint("Data File Ready",False,messageType.REGULAR)
|
||||||
|
|
||||||
def specialPrint(text, inputRequested,type):
|
def specialPrint(text, inputRequested,type):
|
||||||
if(type == messageType.REGULAR):
|
if(type == messageType.REGULAR):
|
||||||
print("-" * 81)
|
print("-" * 81)
|
||||||
print(text)
|
print('====> ', end='')
|
||||||
|
print(text, end= " <====\n")
|
||||||
print("-" * 81 + "\n")
|
print("-" * 81 + "\n")
|
||||||
if(inputRequested):
|
if(inputRequested):
|
||||||
inputReceived = input()
|
inputReceived = input()
|
||||||
@@ -242,26 +276,32 @@ def specialPrint(text, inputRequested,type):
|
|||||||
print("*" * 81 + "\n")
|
print("*" * 81 + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ex():
|
def ex():
|
||||||
|
# playSound()
|
||||||
"""
|
"""
|
||||||
One Time experimental setup
|
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()
|
experimentConditionMatrix = loadFile()
|
||||||
allowPrinting = True
|
title = str(experimentConditionMatrix[0][0])
|
||||||
|
specialPrint("Title is: " + title, False, messageType.REGULAR)
|
||||||
|
allowPrinting = False
|
||||||
isNewExperiment = True
|
isNewExperiment = True
|
||||||
experimentCount = 0
|
experimentCount = int(startAt)
|
||||||
"""
|
"""
|
||||||
Experiment Loop
|
Experiment Loop
|
||||||
"""
|
"""
|
||||||
while(experimentCount<len(experimentConditionMatrix)):
|
while(experimentCount<len(experimentConditionMatrix)):
|
||||||
setUp()
|
setUp()
|
||||||
currentConditions = experimentConditionMatrix[experimentCount+1]
|
currentConditions = experimentConditionMatrix[experimentCount]
|
||||||
exitExperimentLoop = runExperiment(title,currentConditions,allowPrinting,isNewExperiment)
|
exitExperimentLoop = runExperiment(title,currentConditions,allowPrinting,isNewExperiment,(experimentCount+1))
|
||||||
if(exitExperimentLoop):
|
if(exitExperimentLoop):
|
||||||
break
|
break
|
||||||
experimentCount+=1
|
experimentCount+=1
|
||||||
cleanUp(title)
|
cleanUp((experimentCount),title)
|
||||||
|
# pag.alert(text="Experiment " + str(experimentCount+1) + " complete. Starting new Experiment", title="EXPERIMENT STATUS UPDATE")
|
||||||
"""
|
"""
|
||||||
End of Experiments
|
End of Experiments
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user