eaglelandsonce commited on
Commit
9568bdf
·
verified ·
1 Parent(s): ebab5b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -39,6 +39,7 @@ docking_altitude_km = st.sidebar.number_input("Docking Altitude (km)", min_value
39
  run_sim = st.sidebar.button("Run Simulation")
40
 
41
  if run_sim:
 
42
  # ===============================
43
  # Physical Constants and Conversions
44
  # ===============================
@@ -145,19 +146,25 @@ if run_sim:
145
  x_vals = states[:frame+1, 1] / 1000 # convert m to km
146
  y_vals = states[:frame+1, 2] / 1000 # convert m to km
147
  trajectory_line.set_data(x_vals, y_vals)
148
- # Wrap the current marker coordinates in a list so they are interpreted as sequences:
149
  payload_marker.set_data([states[frame, 1] / 1000], [states[frame, 2] / 1000])
150
  time_text.set_text(f"Time: {t_val:.1f} s")
151
  return trajectory_line, payload_marker, time_text
152
 
153
- # Create the animation. The interval (in ms) can be adjusted for speed.
154
  anim = FuncAnimation(fig, update, frames=len(states), init_func=init, interval=20, blit=True)
155
 
156
  # Convert the animation to an HTML5 video.
157
  video_html = anim.to_html5_video()
158
 
159
- st.markdown("### Simulation Animation")
160
- components.html(video_html, height=500)
 
 
 
 
 
 
161
 
162
  st.markdown(
163
  """
 
39
  run_sim = st.sidebar.button("Run Simulation")
40
 
41
  if run_sim:
42
+ st.info("Running simulation... Please wait.")
43
  # ===============================
44
  # Physical Constants and Conversions
45
  # ===============================
 
146
  x_vals = states[:frame+1, 1] / 1000 # convert m to km
147
  y_vals = states[:frame+1, 2] / 1000 # convert m to km
148
  trajectory_line.set_data(x_vals, y_vals)
149
+ # Wrap coordinates in a list so that they are interpreted as sequences:
150
  payload_marker.set_data([states[frame, 1] / 1000], [states[frame, 2] / 1000])
151
  time_text.set_text(f"Time: {t_val:.1f} s")
152
  return trajectory_line, payload_marker, time_text
153
 
154
+ # Create the animation. Adjust the interval (ms) for playback speed.
155
  anim = FuncAnimation(fig, update, frames=len(states), init_func=init, interval=20, blit=True)
156
 
157
  # Convert the animation to an HTML5 video.
158
  video_html = anim.to_html5_video()
159
 
160
+ if video_html:
161
+ st.markdown("### Simulation Animation")
162
+ # Option 1: Use streamlit components to embed the HTML video
163
+ components.html(video_html, height=500)
164
+ # Option 2: Alternatively, use st.markdown (uncomment the following line to try it)
165
+ # st.markdown(video_html, unsafe_allow_html=True)
166
+ else:
167
+ st.error("No video generated. Please ensure that ffmpeg is installed and properly configured.")
168
 
169
  st.markdown(
170
  """