MAJOR FIX: Recconect Loop working with dictionaries holding state parameters
This commit is contained in:
@@ -11,11 +11,11 @@ class scaleFactor():
|
|||||||
|
|
||||||
###Define variables/parameters for aircraft class/category : Wisdom of Raju
|
###Define variables/parameters for aircraft class/category : Wisdom of Raju
|
||||||
class AircraftLandingModel(pyactr.ACTRModel):
|
class AircraftLandingModel(pyactr.ACTRModel):
|
||||||
def __init__(self,client):
|
def __init__(self,client,printFlag):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.client = client
|
self.client = client
|
||||||
self.inProgress = True
|
self.inProgress = True
|
||||||
self.printControlsFlag = False
|
self.printControlsFlag = printFlag
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Setting DREF variables and loading into drefs array
|
Setting DREF variables and loading into drefs array
|
||||||
@@ -35,13 +35,14 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
"airspeed" : airspeedDREF,
|
"airspeed" : airspeedDREF,
|
||||||
"roll" : rollDREF,
|
"roll" : rollDREF,
|
||||||
"heading" : magneticHeadingDREF,
|
"heading" : magneticHeadingDREF,
|
||||||
"verticalSpeed" : verticalSpeedDREF,
|
"vertical speed" : verticalSpeedDREF,
|
||||||
"altitude": altitudeAGLDREF,
|
"altitude": altitudeAGLDREF,
|
||||||
"pitch" : pitchDREF,
|
"pitch" : pitchDREF,
|
||||||
"brake": brakeDREF,
|
"brakes": brakeDREF,
|
||||||
"wheelSpeed": wheelSpeedDREF,
|
"wheelSpeed": wheelSpeedDREF,
|
||||||
"wheelWeight": wheelWeightDREF
|
"wheelWeight": wheelWeightDREF
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Initial Initialization of destination Variables and loading into destinations array
|
Initial Initialization of destination Variables and loading into destinations array
|
||||||
"""
|
"""
|
||||||
@@ -71,13 +72,14 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
"airspeed" : self.airspeed,
|
"airspeed" : self.airspeed,
|
||||||
"roll" : self.roll,
|
"roll" : self.roll,
|
||||||
"heading" : self.heading,
|
"heading" : self.heading,
|
||||||
"verticalSpeed" : self.descent_rate,
|
"vertical speed" : self.descent_rate,
|
||||||
"altitude": self.altitude,
|
"altitude": self.altitude,
|
||||||
"pitch" : self.pitch,
|
"pitch" : self.pitch,
|
||||||
"brake": self.brakes,
|
"brakes": self.brakes,
|
||||||
"wheelSpeed": self.wheelSpeed,
|
"wheelSpeed": self.wheelSpeed,
|
||||||
"wheelWeight": self.wheelWeight
|
"wheelWeight": self.wheelWeight
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Initial Initialization of target Values
|
Initial Initialization of target Values
|
||||||
"""
|
"""
|
||||||
@@ -95,7 +97,12 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
self.flare = False
|
self.flare = False
|
||||||
self.rollOut = False
|
self.rollOut = False
|
||||||
self.currentState = 0
|
self.currentState = 0
|
||||||
self.stateFlags = [self.descent,self.flare,self.rollOut]
|
# self.stateFlags = [self.descent,self.flare,self.rollOut]
|
||||||
|
self.phaseFlags = {
|
||||||
|
"descent" : self.descent,
|
||||||
|
"flare" : self.flare,
|
||||||
|
"roll out" : self.rollOut
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Declare the state for previous values
|
# Declare the state for previous values
|
||||||
@@ -127,6 +134,18 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# while(idx < len(self.sources) - 1):
|
# while(idx < len(self.sources) - 1):
|
||||||
# self.variableAtlas[0] = [self.sources[idx],self.destinations[idx],self.targets[idx]]
|
# self.variableAtlas[0] = [self.sources[idx],self.destinations[idx],self.targets[idx]]
|
||||||
# idx += 1
|
# idx += 1
|
||||||
|
|
||||||
|
def dictionaryAccess(self,dictionary,key):
|
||||||
|
# print("dictionary access for: " + str(key))
|
||||||
|
result = dictionary[key]
|
||||||
|
if isinstance(result, tuple):
|
||||||
|
return result[0]
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reassignClient(self,newClient):
|
def reassignClient(self,newClient):
|
||||||
self.client = newClient
|
self.client = newClient
|
||||||
|
|
||||||
@@ -136,9 +155,9 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
for key in self.sources:
|
for key in self.sources:
|
||||||
self.destinations[key] = results[idx]
|
self.destinations[key] = results[idx]
|
||||||
idx+=1
|
idx+=1
|
||||||
print("getDrefs: " + str(results[1][0]))
|
# print("getDrefs: " + str(results[1][0]))
|
||||||
print("current destination: " + str(self.destinations["airspeed"]))
|
# print("current destination: " + str(self.destinations["airspeed"]))
|
||||||
print("current main Airspeed: " + str(self.airspeed))
|
# print("current main Airspeed: " + str(self.airspeed))
|
||||||
|
|
||||||
# while(idx < len(results) - 2):
|
# while(idx < len(results) - 2):
|
||||||
# self.destinations[idx] = results[idx][0]
|
# self.destinations[idx] = results[idx][0]
|
||||||
@@ -150,17 +169,18 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
|
|
||||||
|
|
||||||
def printControls(self,calculated,errors,yokePull,yokeSteer,rudder,throttle):
|
def printControls(self,calculated,errors,yokePull,yokeSteer,rudder,throttle):
|
||||||
print("In print controls")
|
# print("In print controls")
|
||||||
if(calculated == 1):
|
if(calculated == 1):
|
||||||
# print("* Calculated Controls *")
|
# print("* Calculated Controls *")
|
||||||
# print("*Parameter,Target,Current,Yoke Pull: " + "Airspeed, " + str(self.target_airspeed) + "," + str(self.airspeed)+ "," + str(yokePull))
|
# print("*Parameter,Target,Current,Yoke Pull: " + "Airspeed, " + str(self.target_airspeed) + "," + str(self.airspeed)+ "," + str(yokePull))
|
||||||
# print("*Parameter,Target,Current,Yoke Steer: " + "Roll, " + str(self.target_roll) + "," + str(self.roll)+ "," + str(yokeSteer))
|
# print("*Parameter,Target,Current,Yoke Steer: " + "Roll, " + str(self.target_roll) + "," + str(self.destinations["roll"])+ "," + str(yokeSteer))
|
||||||
# print("*Parameter,Target,Current,Rudder: " + "Heading, " + str(self.target_heading) + "," + str(self.heading)+ "," + str(rudder))
|
# print("*Parameter,Target,Current,Rudder: " + "Heading, " + str(self.target_heading) + "," + str(self.heading)+ "," + str(rudder))
|
||||||
# print("*Parameter,Target,Current,Throttle: " + "Descent Rate, " + str(self.target_descent_rate) + "," + str(self.descent_rate)+ "," + str(throttle))
|
# print("*Parameter,Target,Current,Throttle: " + "Descent Rate, " + str(self.target_descent_rate) + "," + str(self.descent_rate)+ "," + str(throttle))
|
||||||
parameter = ["Airspeed","Roll","Heading","Descent Rate","Altitude","Flare: Pitch", "Brakes: Wheel Speed", "Brakes: Wheel Weight"]
|
parameter = ["Airspeed","Roll","Heading","Descent Rate","Altitude","Flare: Pitch", "Brakes: Wheel Speed", "Brakes: Wheel Weight"]
|
||||||
target = [str(round(self.target_airspeed)),str(round(self.target_roll)),str(round(self.target_heading,3)),str(round(self.target_descent_rate,3)),str(round(self.altitude,3)),str(round(self.target_pitch,3)),0, 0]
|
target = [str(round(self.target_airspeed)),str(round(self.target_roll)),str(round(self.target_heading,3)),str(round(self.target_descent_rate,3)),str(round(self.altitude,3)),str(round(self.target_pitch,3)),0, 0]
|
||||||
current = [str(round(self.destinations["airspeed"],3)),str(round(self.roll,3)),str(round(self.heading,3)),str(round(self.descent_rate,3)),str(round(self.altitude,3)),str(round(self.pitch,3)),str(round(self.wheelSpeed,3)),str(round(self.wheelWeight,3))]
|
current = [str(round(self.dictionaryAccess(self.destinations,"pitch"),3)),str(round(self.dictionaryAccess(self.destinations,"roll"),3)),str(round(self.dictionaryAccess(self.destinations,"heading"),3)),str(round(self.dictionaryAccess(self.destinations,"vertical speed"),3)),
|
||||||
controlVal = [str(round(yokePull,3)),str(round(yokeSteer,3)),str(round(rudder,3)),str(round(throttle,3)),str(round(self.altitude,3)),str(self.flare),str(round(self.brakes,3)),str(round(self.brakes,3))]
|
str(round(self.dictionaryAccess(self.destinations,"altitude"),3)),str(round(self.dictionaryAccess(self.destinations,"pitch"),3)),str(round(self.dictionaryAccess(self.destinations,"wheelSpeed"),3)),str(round(self.dictionaryAccess(self.destinations,"wheelWeight"),3))]
|
||||||
|
controlVal = [str(round(yokePull,3)),str(round(yokeSteer,3)),str(round(rudder,3)),str(round(throttle,3)),str(round(self.altitude,3)),str(self.dictionaryAccess(self.phaseFlags,"flare")),str(round(self.dictionaryAccess(self.destinations,"brakes"),3)),str(round(self.dictionaryAccess(self.destinations,"brakes"),3))]
|
||||||
|
|
||||||
header_row = "{:<20} {:<20} {:<20} {:>10}"
|
header_row = "{:<20} {:<20} {:<20} {:>10}"
|
||||||
headers = "Parameter Target Current Control_Value".split()
|
headers = "Parameter Target Current Control_Value".split()
|
||||||
@@ -226,16 +246,15 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# print("In update controls")
|
# print("In update controls")
|
||||||
# print("Entered Update Controls Simultaneously")
|
# print("Entered Update Controls Simultaneously")
|
||||||
# Compute control values for all parameters (yoke pull, yoke steer, rudder, throttle)
|
# Compute control values for all parameters (yoke pull, yoke steer, rudder, throttle)
|
||||||
if(self.flare):
|
if(self.dictionaryAccess(self.phaseFlags,"flare")):
|
||||||
yoke_pull, self.integral_airspeed = self.proportionalIntegralControl(1,self.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)
|
||||||
print("Flare Control Scheme Active")
|
|
||||||
|
|
||||||
if(self.flare == False):
|
if(self.dictionaryAccess(self.phaseFlags,"flare") == False):
|
||||||
self.target_pitch = 10
|
self.target_pitch = 10
|
||||||
yoke_pull, self.integral_airspeed = self.proportionalIntegralControl(1,self.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)
|
||||||
@@ -244,22 +263,23 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# self.integral_airspeed,
|
# self.integral_airspeed,
|
||||||
# scaleFactor.SCALEYOKEPULL)
|
# scaleFactor.SCALEYOKEPULL)
|
||||||
|
|
||||||
yoke_steer, self.integral_roll = self.proportionalIntegralControl(0,self.roll, self.target_roll, self.integral_roll,scaleFactor.SCALEYOKESTEER)
|
yoke_steer, self.integral_roll = self.proportionalIntegralControl(0,self.dictionaryAccess(self.destinations,"roll"), self.target_roll, self.integral_roll,scaleFactor.SCALEYOKESTEER)
|
||||||
rudder, self.integral_heading = self.proportionalIntegralControl(0,self.heading, self.target_heading, self.integral_heading,scaleFactor.SCALERUDDER)
|
rudder, self.integral_heading = self.proportionalIntegralControl(0,self.dictionaryAccess(self.destinations,"heading"), self.target_heading, self.integral_heading,scaleFactor.SCALERUDDER)
|
||||||
throttle, self.integral_descent_rate = self.proportionalIntegralControl(0,self.descent_rate, self.target_descent_rate, self.integral_descent_rate,scaleFactor.SCALETHROTTLE)
|
throttle, self.integral_descent_rate = self.proportionalIntegralControl(0,self.dictionaryAccess(self.destinations,"vertical speed"), self.target_descent_rate, self.integral_descent_rate,scaleFactor.SCALETHROTTLE)
|
||||||
### 1. For Calculated Yoke and Throttle Values
|
### 1. For Calculated Yoke and Throttle Values
|
||||||
#Invert Throttle Control & divide by 5 to scale
|
#Invert Throttle Control & divide by 5 to scale
|
||||||
|
|
||||||
throttle = -throttle
|
throttle = -throttle
|
||||||
throttle = throttle/5
|
throttle = throttle/5
|
||||||
#Invert Yoke Pull & divide by 5 to scale
|
#Invert Yoke Pull & divide by 5 to scale
|
||||||
yoke_pull = yoke_pull/5
|
yoke_pull = yoke_pull/5
|
||||||
## 2. For Constant Yoke and Throttle Values
|
## 2. For Constant Yoke and Throttle Values
|
||||||
# Constant yoke "back pressure" equal to 20% of total travel distance
|
# Constant yoke "back pressure" equal to 20% of total travel distance
|
||||||
if(self.flare == False):
|
if(self.dictionaryAccess(self.phaseFlags,"flare") == False):
|
||||||
yoke_pull = yoke_pull * 20
|
yoke_pull = yoke_pull * 20
|
||||||
# yoke_pull = 0.23
|
# yoke_pull = 0.23
|
||||||
throttle = 0.28
|
throttle = 0.28
|
||||||
if(self.flare == True):
|
if(self.dictionaryAccess(self.phaseFlags,"flare") == True):
|
||||||
# yoke_pull = -yoke_pull
|
# yoke_pull = -yoke_pull
|
||||||
yoke_pull = yoke_pull * 20
|
yoke_pull = yoke_pull * 20
|
||||||
throttle = 0
|
throttle = 0
|
||||||
@@ -302,17 +322,17 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# print("Yoke Pull:" + str(yoke_pull))
|
# print("Yoke Pull:" + str(yoke_pull))
|
||||||
|
|
||||||
#Set the Trim to a value that allows the aircraft to osscilate around the target airspeed
|
#Set the Trim to a value that allows the aircraft to osscilate around the target airspeed
|
||||||
if(self.flare == False):
|
if(self.dictionaryAccess(self.phaseFlags,"flare") == False):
|
||||||
trimdref = "sim/flightmodel/controls/elv_trim"
|
trimdref = "sim/flightmodel/controls/elv_trim"
|
||||||
trim = -0.3
|
trim = -0.3
|
||||||
self.client.sendDREF(trimdref,trim)
|
self.client.sendDREF(trimdref,trim)
|
||||||
|
|
||||||
if(self.flare):
|
if(self.dictionaryAccess(self.phaseFlags,"flare")):
|
||||||
trimdref = "sim/flightmodel/controls/elv_trim"
|
trimdref = "sim/flightmodel/controls/elv_trim"
|
||||||
trim = 0
|
trim = 0
|
||||||
self.client.sendDREF(trimdref,trim)
|
self.client.sendDREF(trimdref,trim)
|
||||||
|
|
||||||
if(self.rollOut):
|
if(self.dictionaryAccess(self.phaseFlags,"roll out")):
|
||||||
#Cut the Throttle
|
#Cut the Throttle
|
||||||
throttle = 0
|
throttle = 0
|
||||||
#Release Yoke Back Pressure (Pitch Up Pressure from the flare maneuver)
|
#Release Yoke Back Pressure (Pitch Up Pressure from the flare maneuver)
|
||||||
@@ -325,19 +345,26 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
self.client.sendCTRL([yoke_pull, yoke_steer, rudder, throttle, -998, -998]) # Control inputs: [yoke_pull, yoke_steer, rudder, throttle]
|
self.client.sendCTRL([yoke_pull, yoke_steer, rudder, throttle, -998, -998]) # Control inputs: [yoke_pull, yoke_steer, rudder, throttle]
|
||||||
|
|
||||||
def conditionChecks(self):
|
def conditionChecks(self):
|
||||||
if(self.wheelWeight > 0.01 and self.wheelSpeed > 1):
|
|
||||||
|
if(self.dictionaryAccess(self.destinations,"wheelWeight") > 0.01
|
||||||
|
and self.dictionaryAccess(self.destinations,"wheelSpeed") > 1):
|
||||||
#Two Parameters to Confirm Touchdown and wheel contact
|
#Two Parameters to Confirm Touchdown and wheel contact
|
||||||
# "sim/flightmodel/parts/tire_vrt_def_veh" #Gear Strut Deflection (Weight on wheels)
|
# "sim/flightmodel/parts/tire_vrt_def_veh" #Gear Strut Deflection (Weight on wheels)
|
||||||
# "sim/flightmodel2/gear/tire_rotation_rate_rad_sec" #Tire Rotation Rate
|
# "sim/flightmodel2/gear/tire_rotation_rate_rad_sec" #Tire Rotation Rate
|
||||||
self.rollOut = True
|
self.phaseFlags["roll out"] = True
|
||||||
print("Hit the brakes")
|
print("Hit the brakes")
|
||||||
|
|
||||||
if(self.altitude <= 20):
|
if(self.dictionaryAccess(self.destinations,"altitude") <= 20
|
||||||
self.flare = True
|
and self.dictionaryAccess(self.phaseFlags,"flare") == False):
|
||||||
|
self.phaseFlags["flare"] = True
|
||||||
self.Ki = 0.01 ## Increase Control Authority to compensate for decreasing airspeed
|
self.Ki = 0.01 ## Increase Control Authority to compensate for decreasing airspeed
|
||||||
print("Altitude < 500; Flare Set True")
|
print("Altitude < 500; Flare Set True")
|
||||||
|
print("*******FLAG*******")
|
||||||
|
|
||||||
if(self.wheelWeight > 0.01 and self.wheelSpeed > 1 and self.destinations["airspeed"] < 1 and self.brakes == 1):
|
if(self.dictionaryAccess(self.destinations,"wheelWeight") > 0.01
|
||||||
|
and self.dictionaryAccess(self.destinations,"wheelSpeed") < 1
|
||||||
|
and self.dictionaryAccess(self.destinations,"airspeed") < 2
|
||||||
|
and self.dictionaryAccess(self.destinations,"brakes") == 1):
|
||||||
self.inProgress = False
|
self.inProgress = False
|
||||||
|
|
||||||
def simulationStatus(self):
|
def simulationStatus(self):
|
||||||
@@ -350,6 +377,7 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
Faster Method
|
Faster Method
|
||||||
"""
|
"""
|
||||||
self.getAndLoadDREFS()
|
self.getAndLoadDREFS()
|
||||||
|
print("midpoint")
|
||||||
self.conditionChecks()
|
self.conditionChecks()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import xpc
|
import xpc
|
||||||
@@ -12,7 +13,8 @@ def runExperiment(title):
|
|||||||
startTime = 0
|
startTime = 0
|
||||||
endTime = 0
|
endTime = 0
|
||||||
difference = endTime - startTime
|
difference = endTime - startTime
|
||||||
while(difference < 10):
|
experimentLive = True
|
||||||
|
while(difference < 3 and experimentLive):
|
||||||
print("Time Elapsed: -----> " + str(difference))
|
print("Time Elapsed: -----> " + str(difference))
|
||||||
try:
|
try:
|
||||||
with xpc.XPlaneConnect() as client:
|
with xpc.XPlaneConnect() as client:
|
||||||
@@ -25,7 +27,7 @@ def runExperiment(title):
|
|||||||
# print("Error establishing connection to X-Plane.")
|
# print("Error establishing connection to X-Plane.")
|
||||||
# print("Exiting...")
|
# print("Exiting...")
|
||||||
# return
|
# return
|
||||||
cogModel = AircraftLandingModel(client)
|
cogModel = AircraftLandingModel(client,True)
|
||||||
# # 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
|
||||||
@@ -117,11 +119,11 @@ def runExperiment(title):
|
|||||||
client.pauseSim(False)
|
client.pauseSim(False)
|
||||||
|
|
||||||
# 39.96239°N/104.69713°W
|
# 39.96239°N/104.69713°W
|
||||||
runModel = True
|
# # 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)
|
||||||
|
print("past setting controls")
|
||||||
# Pitch, Roll, Rudder, Throttle
|
# Pitch, Roll, Rudder, Throttle
|
||||||
# Pause the sim
|
# Pause the sim
|
||||||
# client.pauseSim(False)
|
# client.pauseSim(False)
|
||||||
@@ -130,11 +132,15 @@ def runExperiment(title):
|
|||||||
clockStart = time.time()
|
clockStart = time.time()
|
||||||
#Doing stuff In between Test SECOND INCREMENTS
|
#Doing stuff In between Test SECOND INCREMENTS
|
||||||
retry = 0
|
retry = 0
|
||||||
while(cogModel.simulationStatus() and runModel and retry < 50):
|
while(cogModel.simulationStatus()):
|
||||||
|
# print("Start of innerwhile loop")
|
||||||
clockStart = time.time() #START TIMER
|
clockStart = time.time() #START TIMER
|
||||||
# client.pauseSim(True) # Pause Simulator
|
# client.pauseSim(True) # Pause Simulator
|
||||||
#Run Model
|
#Run Model
|
||||||
|
# print("----------------> 1 <")
|
||||||
cogModel.update_aircraft_state()
|
cogModel.update_aircraft_state()
|
||||||
|
# print("----------------> 2 <")
|
||||||
|
|
||||||
cogModel.update_controls_simultaneously()
|
cogModel.update_controls_simultaneously()
|
||||||
client.pauseSim(False) #Unpause Simulator
|
client.pauseSim(False) #Unpause Simulator
|
||||||
clockEnd = time.time() # STOP TIMER
|
clockEnd = time.time() # STOP TIMER
|
||||||
@@ -184,31 +190,38 @@ def runExperiment(title):
|
|||||||
# print("Breaking out of Timeout exception loop")
|
# print("Breaking out of Timeout exception loop")
|
||||||
# break
|
# break
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
|
experimentLive = cogModel.simulationStatus()
|
||||||
except:
|
except:
|
||||||
print("except detected")
|
print("except detected")
|
||||||
endTime = time.time()
|
endTime = time.time()
|
||||||
|
print("Start Time:" + str(startTime))
|
||||||
|
print("End Time:" + str(endTime))
|
||||||
difference = endTime - startTime
|
difference = endTime - startTime
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if(difference >= 3):
|
||||||
|
print("Timeout[" + str(difference) +"]:"+"Error, please run test again")
|
||||||
|
else:
|
||||||
print("Model has finished running")
|
print("Model has finished running")
|
||||||
|
|
||||||
#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")
|
||||||
|
os.remove("/Users/flyingtopher/X-Plane 11/Data.txt")
|
||||||
|
print("CLEAN UP: Data File Deleted and Reset")
|
||||||
input("Press any key to exit...")
|
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)
|
##Reset the sim with the keyboard shortcut (wrapper around model that waits for reconnection)
|
||||||
|
|
||||||
def ex():
|
def ex():
|
||||||
##Store Experiment Battery
|
##Store Experiment Battery
|
||||||
|
|
||||||
##Different paramters on every run of the model
|
##Different paramters on every run of the model
|
||||||
## Nested loops:
|
## Nested loops:
|
||||||
##wind conditions, pilot conditions
|
##wind conditions, pilot conditions
|
||||||
title = input("Please Enter Experiment Set Title, leave blank for trial runs")
|
title = input("Please Enter Experiment Set Title, leave blank for trial runs")
|
||||||
count = 0
|
count = 0
|
||||||
while(count<1):
|
while(count<2):
|
||||||
|
input("Press Enter to Start Experiment #" + str(count) + ": ")
|
||||||
runExperiment(title)
|
runExperiment(title)
|
||||||
count+=1
|
count+=1
|
||||||
print("Experiment Battery Complete")
|
print("Experiment Battery Complete")
|
||||||
|
|||||||
Reference in New Issue
Block a user