Pre-
Timing Improvements Automatic Location Setting
This commit is contained in:
@@ -29,6 +29,10 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
self.client = client
|
self.client = client
|
||||||
|
# TODO: CHANGE TO GETDREFS, respect the runtime calculations.....didnt you learn your lesson on the algorithms midterm
|
||||||
|
# TODO: Change sendDref to send DREFS
|
||||||
|
# TODO: look for any rouge get/sendCTRL methods
|
||||||
|
|
||||||
airspeed = self.client.getDREF("sim/cockpit2/gauges/indicators/airspeed_kts_pilot")
|
airspeed = self.client.getDREF("sim/cockpit2/gauges/indicators/airspeed_kts_pilot")
|
||||||
roll = self.client.getDREF("sim/cockpit2/gauges/indicators/roll_AHARS_deg_pilot")
|
roll = self.client.getDREF("sim/cockpit2/gauges/indicators/roll_AHARS_deg_pilot")
|
||||||
heading = self.client.getDREF("sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot")
|
heading = self.client.getDREF("sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot")
|
||||||
@@ -44,6 +48,7 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Update the model's declarative memory
|
# Update the model's declarative memory
|
||||||
# model.declarative_memory["airspeed"] = airspeed
|
# model.declarative_memory["airspeed"] = airspeed
|
||||||
# model.declarative_memory["roll"] = roll
|
# model.declarative_memory["roll"] = roll
|
||||||
@@ -243,7 +248,7 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
|
|
||||||
#Switch Target for Pitch to Local Pitch Axis (ex. +10 Degrees nose up)
|
#Switch Target for Pitch to Local Pitch Axis (ex. +10 Degrees nose up)
|
||||||
|
|
||||||
self.printControls(1,0,yoke_pull,yoke_steer,rudder,throttle)
|
# self.printControls(1,0,yoke_pull,yoke_steer,rudder,throttle) #PRINT CONTROLS
|
||||||
# Send all controls simultaneously to X-Plane
|
# Send all controls simultaneously to X-Plane
|
||||||
self.send_controls_to_xplane(yoke_pull, yoke_steer, rudder, throttle)
|
self.send_controls_to_xplane(yoke_pull, yoke_steer, rudder, throttle)
|
||||||
|
|
||||||
@@ -333,6 +338,8 @@ class AircraftLandingModel(pyactr.ACTRModel):
|
|||||||
print("Hit the brakes")
|
print("Hit the brakes")
|
||||||
|
|
||||||
|
|
||||||
|
# def logData(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Disturbances & Disturbance Tests (Demonstrate the limitations of the model)
|
|||||||
1. Get model as is to land at the "ideal" point
|
1. Get model as is to land at the "ideal" point
|
||||||
|
|
||||||
2. Graph Production from the simulation
|
2. Graph Production from the simulation
|
||||||
1. Dump Raw Data during simulation
|
1. Dump Raw Data during simulation (achieved)
|
||||||
2. Second peice of code, looks at raw data, produces the graphs/or the numbers that get pasted into excel
|
2. Second peice of code, looks at raw data, produces the graphs/or the numbers that get pasted into excel
|
||||||
3. Create fancy graphs (The punchline of the story)
|
3. Create fancy graphs (The punchline of the story)
|
||||||
--- Slide with graphs that can make consistent comparisons
|
--- Slide with graphs that can make consistent comparisons
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import xpc
|
import xpc
|
||||||
from cognitiveModel import AircraftLandingModel
|
from cognitiveModel import AircraftLandingModel
|
||||||
@@ -17,7 +18,6 @@ def ex():
|
|||||||
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)
|
||||||
|
|
||||||
# # Set position of the player aircraft
|
# # Set position of the player aircraft
|
||||||
@@ -43,96 +43,65 @@ def ex():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# client.pauseSim(True)
|
||||||
|
# # Set position of the player aircraft
|
||||||
|
# print("Setting Experiment Position: Denver Airport Runway")
|
||||||
|
# # Lat Lon Alt Pitch Roll Yaw Gear
|
||||||
|
# posi = [39.945, -104.70, 2500, 0, 0, 0, 1] #3NM Approach for Denver Intl Runway 16R (16,000 feet)
|
||||||
|
# client.sendPOSI(posi)
|
||||||
|
# quat = (1.0,0.0,0.0,173.0)
|
||||||
|
# quatDref = "sim/flightmodel/position/q"
|
||||||
|
# client.sendDREF(quatDref,quat)
|
||||||
|
# speed = (1.0,0.0,0.0,173.0)
|
||||||
|
# client.sendDREF("sim/flightmodel/position/indicated_airspeed",speed)
|
||||||
|
# client.pauseSim(False)
|
||||||
|
|
||||||
|
|
||||||
|
# # Set angle of attack, velocity, and orientation using the DATA command
|
||||||
|
# print("Setting orientation")
|
||||||
|
# data = [\
|
||||||
|
# [18, 0, -998, 0, -998, -998, -998, -998, -998],\
|
||||||
|
# [ 3, 130, 130, 130, 130, -998, -998, -998, -998],\
|
||||||
|
# [16, 0, 0, 0, -998, -998, -998, -998, -998]\
|
||||||
|
# ]
|
||||||
|
# client.sendDATA(data)
|
||||||
|
|
||||||
# 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)
|
||||||
# Pitch, Roll, Rudder, Throttle
|
# Pitch, Roll, Rudder, Throttle
|
||||||
|
|
||||||
# Pause the sim
|
# Pause the sim
|
||||||
client.pauseSim(False)
|
client.pauseSim(False)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
innercount = 0
|
innercount = 0
|
||||||
#ONE SECOND INCREMENTS
|
clockStart = time.time()
|
||||||
# while(count < 1000000 ):
|
|
||||||
# client.pauseSim(False)
|
|
||||||
# sleep(1.0)
|
|
||||||
# print("Pausing" + str(count))
|
|
||||||
# client.pauseSim(True)
|
|
||||||
# sleep(1.0)
|
|
||||||
# count+=1
|
|
||||||
|
|
||||||
#0.1 SECOND INCREMENTS
|
|
||||||
# while(count < 1000000 ):
|
|
||||||
# client.pauseSim(False)
|
|
||||||
# sleep(0.1)
|
|
||||||
# print("Pausing" + str(count))
|
|
||||||
# client.pauseSim(True)
|
|
||||||
# sleep(0.1)
|
|
||||||
# count+=1
|
|
||||||
|
|
||||||
#0.001 SECOND INCREMENTS
|
|
||||||
# while(count < 1000000 ):
|
|
||||||
# client.pauseSim(False)
|
|
||||||
# sleep(0.001)
|
|
||||||
# print("Pausing" + str(count))
|
|
||||||
# client.pauseSim(True)
|
|
||||||
# sleep(0.001)
|
|
||||||
# count+=1
|
|
||||||
|
|
||||||
#0.00001 SECOND INCREMENTS
|
|
||||||
# while(count < 1000000 ):
|
|
||||||
# client.pauseSim(False)
|
|
||||||
# sleep(0.00001)
|
|
||||||
# print("Pausing" + str(count))
|
|
||||||
# client.pauseSim(True)
|
|
||||||
# sleep(0.00001)
|
|
||||||
# count+=1
|
|
||||||
|
|
||||||
|
|
||||||
# sim/operation/override/override_timestep
|
|
||||||
|
|
||||||
#Doing stuff In between Test SECOND INCREMENTS
|
#Doing stuff In between Test SECOND INCREMENTS
|
||||||
while(count < 1000000):
|
while(count < 1000000):
|
||||||
#50 Millisecond Timesteps
|
clockStart = time.time()
|
||||||
# sleep(0.05)
|
|
||||||
sleep(0.05)
|
|
||||||
|
|
||||||
client.pauseSim(False) #Unpause
|
|
||||||
# sleep(0.05) # Run 50 Milliseconds
|
client.pauseSim(True) # Pause Simulator
|
||||||
# client.pauseSim(True) # Pause Simulator
|
|
||||||
#Run Model (Send commands to simulator within this process)
|
#Run Model (Send commands to simulator within this process)
|
||||||
####Insert Model Here, some assembly required#######
|
|
||||||
cogModel.update_aircraft_state()
|
cogModel.update_aircraft_state()
|
||||||
cogModel.update_controls_simultaneously()
|
cogModel.update_controls_simultaneously()
|
||||||
#Please work........no excuses now
|
client.pauseSim(False) #Unpause
|
||||||
#Repeat
|
|
||||||
# print("Advanced 50 Milliseconds: Step #" + str(count))
|
clockEnd = time.time()
|
||||||
count+=1
|
count+=1
|
||||||
|
print("Clock Time: " + str(clockEnd - clockStart))
|
||||||
|
sleep(0.05) # Run 50 Milliseconds
|
||||||
|
##Would need to be logging data during the sleep time......but the code is "sleeping"....multithread?
|
||||||
|
#Repeat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# print("Pausing" + str(count))
|
#
|
||||||
# innercount = 0
|
|
||||||
# client.pauseSim(True)
|
|
||||||
# sleep(0.05) #Simulate 50 milliseconds
|
|
||||||
|
|
||||||
# sleep(0.01) #Simulate 50 milliseconds
|
|
||||||
# # while(innercount < 100000):
|
|
||||||
# # # print("Doing Stuff" + str(innercount)) # Simulates the model running and computing for 50 Milliseconds maybe?
|
|
||||||
|
|
||||||
# # innercount+=1
|
|
||||||
# # else:
|
|
||||||
# client.pauseSim(False)
|
|
||||||
# print("Exit Pause" + str(count))
|
|
||||||
# sleep(0.5)
|
|
||||||
# count+=1
|
|
||||||
|
|
||||||
print("End of Python client example")
|
print("End of Python client example")
|
||||||
|
#Copy data.txt to the cloudddddd using python magic and accurate filepaths
|
||||||
|
|
||||||
input("Press any key to exit...")
|
input("Press any key to exit...")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user