pre-data structure change to use dictionaries for airspeed, pitch, etc. variables

This commit is contained in:
cs-powell
2025-03-29 00:58:28 -04:00
parent 1df378d7b1
commit 07526ca5a3
3 changed files with 37 additions and 15 deletions

View File

@@ -14,6 +14,8 @@ class AircraftLandingModel(pyactr.ACTRModel):
def __init__(self,client):
super().__init__()
self.client = client
self.inProgress = True
self.printControlsFlag = False
"""
Setting DREF variables and loading into drefs array
@@ -110,6 +112,10 @@ class AircraftLandingModel(pyactr.ACTRModel):
idx = 0
while(idx < len(results) - 2):
self.destinations[idx] = results[idx][0]
if(idx == 1):
print("getDrefs: " + str(results[idx][0]))
print("current destination: " + str(self.destinations[idx]))
print("current main Airspeed: " + str(self.airspeed))
idx += 1
@@ -252,8 +258,8 @@ class AircraftLandingModel(pyactr.ACTRModel):
#Switch Target for Pitch to Local Pitch Axis (ex. +10 Degrees nose up)
# self.printControls(1,0,yoke_pull,yoke_steer,rudder,throttle) #PRINT CONTROLS
if(self.printControlsFlag):
self.printControls(1,0,yoke_pull,yoke_steer,rudder,throttle) #PRINT CONTROLS
# Send all controls simultaneously to X-Plane
self.send_controls_to_xplane(yoke_pull, yoke_steer, rudder, throttle)
@@ -301,6 +307,11 @@ class AircraftLandingModel(pyactr.ACTRModel):
self.Ki = 0.01 ## Increase Control Authority to compensate for decreasing airspeed
print("Altitude < 500; Flare Set True")
if(self.wheelWeight > 0.01 and self.wheelSpeed > 1 and self.airspeed < 1 and self.brakes == 1):
self.inProgress = False
def simulationStatus(self):
return self.inProgress
# Update the model's DM based on X-Plane data

View File

@@ -51,3 +51,11 @@ Feedback a week later
May 13th final draft
##3/28/25
Overhead of unpausing/pausing the simulator
Simulating without Drawing the call:
https://forums.x-plane.org/index.php?/forums/topic/227426-run-x-plane-without-rendering-model/

View File

@@ -1,10 +1,11 @@
import datetime
import time
from time import sleep
import xpc
from cognitiveModel import AircraftLandingModel
import shutil
def runExperiment():
def runExperiment(title):
print("Model Test: Xplane setting up connection")
print("Setting up simulation")
@@ -40,8 +41,6 @@ def runExperiment():
# ]
# client.sendDATA(data)
# client.pauseSim(True)
# # Set position of the player aircraft
# print("Setting Experiment Position: Denver Airport Runway")
@@ -124,33 +123,37 @@ def runExperiment():
innercount = 0
clockStart = time.time()
#Doing stuff In between Test SECOND INCREMENTS
while(count < 1000000 and runModel):
while(cogModel.simulationStatus() and runModel):
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
# print("Clock Time: " + str(clockEnd - clockStart)) ## LOG TIME TAKEN
sleep(0.05) # LET Simulator Run 50 Milliseconds
print("Model has finished running")
#Copy data.txt to the cloudddddd using python magic and accurate filepaths
shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination")
now = datetime.datetime
shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/" + title + "_" + str(now.now()) + "_" + ".txt")
input("Press any key to exit...")
## Copy Data.txt to the repository file for analysis
##Reset the sim with the keyboard shortcut (wrapper around model that waits for reconnection)
def ex():
##Store Experiment Battery
##Different paramters on every run of the model
## Nested loops:
##wind conditions, pilot conditions
title = input("Please Enter Experiment Set Title, leave blank for trial runs")
count = 0
while(count<2):
runExperiment()
runExperiment(title)
count+=1
print("Experiment Battery Complete")