pre-experimentSetUp

This commit is contained in:
cs-powell
2025-03-30 21:54:51 -04:00
parent 44d167bbbb
commit ff32f69292
3 changed files with 53 additions and 48 deletions

View File

@@ -250,7 +250,7 @@ class AircraftLandingModel(pyactr.ACTRModel):
yoke_pull, self.integral_airspeed = self.proportionalIntegralControl(1,self.dictionaryAccess(self.destinations,"pitch"), yoke_pull, self.integral_airspeed = self.proportionalIntegralControl(1,self.dictionaryAccess(self.destinations,"pitch"),
self.target_pitch, self.target_pitch,
self.integral_pitch, self.integral_pitch,
scaleFactor.SCALEYOKEPULL) scaleFactor.SCALEYOKEPULL)
if(self.dictionaryAccess(self.phaseFlags,"flare") == False): if(self.dictionaryAccess(self.phaseFlags,"flare") == False):
self.target_pitch = 10 self.target_pitch = 10

View File

@@ -58,4 +58,46 @@ May 13th final draft
##3/28/25 ##3/28/25
Overhead of unpausing/pausing the simulator Overhead of unpausing/pausing the simulator
Simulating without Drawing the call: Simulating without Drawing the call:
https://forums.x-plane.org/index.php?/forums/topic/227426-run-x-plane-without-rendering-model/ https://forums.x-plane.org/index.php?/forums/topic/227426-run-x-plane-without-rendering-model/
##EXCEPTION TEST BED
# try:
# clockStart = time.time() #START TIMER
# # client.pauseSim(True) # Pause Simulator
# #Run Model
# cogModel.update_aircraft_state()
# cogModel.update_controls_simultaneously()
# client.pauseSim(False) #Unpause Simulator
# clockEnd = time.time() # STOP TIMER
# count+=1
# # print("Clock Time: " + str(clockEnd - clockStart)) ## LOG TIME TAKEN
# sleep(0.05) # LET Simulator Run 50 Milliseconds
# except TimeoutError as e:
# clockStart = time.time()
# difference = 0
# print("Outer exception retry: " + str(retry))
# while(difference<10):
# print("Top of while loop")
# try:
# print("Top of TRY")
# with xpc.XPlaneConnect() as client:
# print("Top of reassign")
# cogModel.reassignClient(client)
# print("Bottom of reassign")
# ##Test the connection
# print("TOP: Testing connection")
# cogModel.client.getDREF("sim/test/test_float") ##EXCEPTION OCCURING HERE
# print("CONNECTION SUCCESFUL!!!!!!")
# print("TRY BLOCK, go back to start: " + str(retry))
# except:
# print("Top of EXCEPT")
# print("EXCEPT BLOCK, go back to start: " + str(retry))
# clockEnd = time.time() # STOP TIMER
# difference = clockEnd - clockStart
# retry+=1
# print("Time Elapsed: -----> " + str(difference))
# ##Do Nothing, go back to start of difference loop
# else:
# print("Breaking out of Timeout exception loop")
# break

View File

@@ -5,6 +5,8 @@ from time import sleep
import xpc import xpc
from cognitiveModel import AircraftLandingModel from cognitiveModel import AircraftLandingModel
import shutil import shutil
def experimentSetUp(client):
def runExperiment(title): def runExperiment(title):
@@ -28,6 +30,8 @@ def runExperiment(title):
# print("Exiting...") # print("Exiting...")
# return # return
cogModel = AircraftLandingModel(client,True) cogModel = AircraftLandingModel(client,True)
experimentSetUp(cogModel.client)
# # Set position of the player aircraft # # Set position of the player aircraft
# print("Setting position") # print("Setting position")
# # Lat Lon Alt Pitch Roll Yaw Gear # # Lat Lon Alt Pitch Roll Yaw Gear
@@ -118,8 +122,7 @@ def runExperiment(title):
client.pauseSim(False) client.pauseSim(False)
# 39.96239°N/104.69713°W # Set control surfaces and throttle of the player aircraft using sendCTRL
# # Set control surfaces and throttle of the player aircraft using sendCTRL
print("Setting controls") print("Setting controls")
ctrl = [0.0, 0.0, 0.0, 0.0] ctrl = [0.0, 0.0, 0.0, 0.0]
client.sendCTRL(ctrl) client.sendCTRL(ctrl)
@@ -130,7 +133,6 @@ def runExperiment(title):
count = 0 count = 0
innercount = 0 innercount = 0
clockStart = time.time() clockStart = time.time()
#Doing stuff In between Test SECOND INCREMENTS
retry = 0 retry = 0
while(cogModel.simulationStatus()): while(cogModel.simulationStatus()):
# print("Start of innerwhile loop") # print("Start of innerwhile loop")
@@ -148,47 +150,6 @@ def runExperiment(title):
# print("Clock Time: " + str(clockEnd - clockStart)) ## LOG TIME TAKEN # print("Clock Time: " + str(clockEnd - clockStart)) ## LOG TIME TAKEN
sleep(0.05) # LET Simulator Run 50 Milliseconds sleep(0.05) # LET Simulator Run 50 Milliseconds
##EXCEPTION TEST BED
# try:
# clockStart = time.time() #START TIMER
# # client.pauseSim(True) # Pause Simulator
# #Run Model
# cogModel.update_aircraft_state()
# cogModel.update_controls_simultaneously()
# client.pauseSim(False) #Unpause Simulator
# clockEnd = time.time() # STOP TIMER
# count+=1
# # print("Clock Time: " + str(clockEnd - clockStart)) ## LOG TIME TAKEN
# sleep(0.05) # LET Simulator Run 50 Milliseconds
# except TimeoutError as e:
# clockStart = time.time()
# difference = 0
# print("Outer exception retry: " + str(retry))
# while(difference<10):
# print("Top of while loop")
# try:
# print("Top of TRY")
# with xpc.XPlaneConnect() as client:
# print("Top of reassign")
# cogModel.reassignClient(client)
# print("Bottom of reassign")
# ##Test the connection
# print("TOP: Testing connection")
# cogModel.client.getDREF("sim/test/test_float") ##EXCEPTION OCCURING HERE
# print("CONNECTION SUCCESFUL!!!!!!")
# print("TRY BLOCK, go back to start: " + str(retry))
# except:
# print("Top of EXCEPT")
# print("EXCEPT BLOCK, go back to start: " + str(retry))
# clockEnd = time.time() # STOP TIMER
# difference = clockEnd - clockStart
# retry+=1
# print("Time Elapsed: -----> " + str(difference))
# ##Do Nothing, go back to start of difference loop
# else:
# print("Breaking out of Timeout exception loop")
# break
startTime = time.time() startTime = time.time()
experimentLive = cogModel.simulationStatus() experimentLive = cogModel.simulationStatus()
except: except:
@@ -207,8 +168,8 @@ def runExperiment(title):
#Copy data.txt to the cloudddddd using python magic and accurate filepaths #Copy data.txt to the cloudddddd using python magic and accurate filepaths
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 + "_" + str(now.now()) + "_" + ".txt")
print("CLEAN UP: Data File Copied and saved") # print("CLEAN UP: Data File Copied and saved")
os.remove("/Users/flyingtopher/X-Plane 11/Data.txt") # os.remove("/Users/flyingtopher/X-Plane 11/Data.txt")
print("CLEAN UP: Data File Deleted and Reset") print("CLEAN UP: Data File Deleted and Reset")
input("Press any key to exit...") input("Press any key to exit...")
##Reset the sim with the keyboard shortcut (wrapper around model that waits for reconnection) ##Reset the sim with the keyboard shortcut (wrapper around model that waits for reconnection)
@@ -222,6 +183,8 @@ def ex():
count = 0 count = 0
while(count<2): while(count<2):
input("Press Enter to Start Experiment #" + str(count) + ": ") input("Press Enter to Start Experiment #" + str(count) + ": ")
print("Data File Reset")
f = open("/Users/flyingtopher/X-Plane 11/Data.txt", 'w')
runExperiment(title) runExperiment(title)
count+=1 count+=1
print("Experiment Battery Complete") print("Experiment Battery Complete")