Skip to content

Commit c5ca44c

Browse files
committed
AngAttackUpdate+BugFixes+AutomatedSimulation
1 parent ad7d140 commit c5ca44c

File tree

1 file changed

+62
-5
lines changed

1 file changed

+62
-5
lines changed

Simulation.Frontend/GUI.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import streamlit as st
22
import requests
33
import json
4+
import time
45
import copy
56
from pandas import *
67
class objectview(object):
@@ -117,13 +118,67 @@ def sideBarInput():
117118
updatedshuttle = None
118119
if st.sidebar.checkbox("updateAngle"):
119120
UpdatedAngleBelowHorizontal = st.sidebar.slider("NewAngleBelowHorizontal",0.0,90.0,6.0)
121+
UpdatedAngleOfAttack = st.sidebar.slider("NewAngleOfAttack",0.0,90.0,6.0)
120122
updatedshuttle = UpdatedShuttle(copy.deepcopy(shuttle))
121123
updatedshuttle.Time = st.sidebar.slider("Applied TimeFrame",0,100,1)
122124
updatedshuttle.shuttle.AngleBelowHorizontal = UpdatedAngleBelowHorizontal
125+
updatedshuttle.shuttle.AngleOfAttack = UpdatedAngleOfAttack
123126
return [shuttle,updatedshuttle]
124127

128+
def autoSimulation(o):
129+
SimulationSpeed = st.slider("Select Simulation Speed", 1, 10, 1)
130+
spTimePmt = st.empty()
131+
spTfPmt = st.empty()
132+
spSpdPmt = st.empty()
133+
spSpeed = st.empty()
134+
spAccPmt = st.empty()
135+
spAccRefPmt = st.empty()
136+
spAcc = st.empty()
137+
spAngPmt = st.empty()
138+
spAng = st.empty()
139+
spAltPmt = st.empty()
140+
spAlt = st.empty()
141+
spDispPmt = st.empty()
142+
spDispEarthPmt = st.empty()
143+
spDisp = st.empty()
144+
spTmpPmt = st.empty()
145+
spGtmpPmt = st.empty()
146+
spTmp = st.empty()
147+
spDragPmt = st.empty()
148+
spDragLiftPmt = st.empty()
149+
spDrag = st.empty()
150+
151+
for i in range(0, len(o.time)):
152+
spTimePmt.markdown("Current Time Elapsed **" + rnd(o.time[i])+"**")
153+
spTfPmt.markdown("Curent TimeFrame **" + str(i) + "**")
154+
155+
spSpdPmt.markdown("The current velocity is **" + rnd(o.vec["velocity"][i])+"**")
156+
spSpeed.line_chart(o.vec[0:i], height=100)
157+
158+
spAccPmt.markdown("Current Absolute Acceleration **" + rnd(o.acc["absAcc"][i]) + "**")
159+
spAcc.line_chart(o.acc[0:i], height=100)
160+
161+
spAngPmt.markdown("Current Angle below Horizontal **" + rnd(-o.angle["angBelowHor"][i]) + "**")
162+
spAng.line_chart(o.angle["angBelowHor"][0:i], height=100)
163+
164+
spAltPmt.markdown("Current Height **" + rnd(o.hgt["height"][i]) + "**")
165+
spAlt.area_chart(o.hgt[0:i], height=100)
166+
167+
spDispPmt.markdown("Current Displacement is **" + rnd(o.disp["disp"][i]) + "**")
168+
spDispEarthPmt.markdown("Current Displacement around Earth **" + rnd(o.disp["dispEarth"][i]) + "**")
169+
spDisp.area_chart(o.disp[0:i], height=100)
170+
171+
spTmpPmt.markdown("The current temp is **" + rnd(o.temp["curTemp"][i]) + "**")
172+
spGtmpPmt.markdown("The maximum temp is **" + rnd(o.temp["maxTemp"][i]) + "**")
173+
spTmp.area_chart(o.temp[0:i], height=100)
174+
175+
spDragPmt.markdown("Current Drag Coefficient **" + rnd(o.drag["dragCoeff"][i]) + "**")
176+
spDragLiftPmt.markdown("Current Lift to Drag **" + rnd(o.drag["liftToDrag"][i]) + "**")
177+
spDrag.line_chart(o.drag[0:i], height=100)
178+
time.sleep(1.0 / SimulationSpeed)
179+
125180
def manualSimulation(o):
126-
i = st.slider("Current TimeFrame", 0, len(o.time))
181+
i = st.slider("Current TimeFrame", 0, len(o.time)-1)
127182
st.markdown("**Please drag TimeFrame slider slowly**")
128183
st.markdown("Current Time Elapsed **" + rnd(o.time[i]) + "**")
129184
st.markdown("Curent TimeFrame **" + str(i) + "**")
@@ -173,10 +228,10 @@ def fetchcombined(sideInput):
173228

174229
def startApp():
175230
st.markdown("# Spacecraft Landing Simulator UI")
176-
input = sideBarInput()
177-
if st.sidebar.checkbox("Hide Prompt and Press Start"):
178-
manualSimulation(convert(fetchcombined(input)))
179-
else:
231+
start = st.sidebar.selectbox("Select Page",("Introduction","Manual Simulation","Automated Simulation"))
232+
if start == "Manual Simulation":
233+
manualSimulation(convert(fetchcombined(sideBarInput())))
234+
elif start == "Introduction":
180235
st.empty()
181236
st.markdown("""
182237
## Instructions:
@@ -196,6 +251,8 @@ def startApp():
196251
This is the board where we brainstorm and sort out how properties are related \n
197252
(Registeration may be required to view the public board)
198253
""")
254+
elif start == "Automated Simulation":
255+
autoSimulation(convert(fetchcombined(sideBarInput())))
199256

200257
if __name__ == '__main__':
201258
startApp()

0 commit comments

Comments
 (0)