chrisjcc commited on
Commit
9436a55
·
verified ·
1 Parent(s): cdee8ac

Introduced a run_counter in app.py to track the number of simulation runs, ensuring each run has a distinct identifier.

Browse files
Files changed (1) hide show
  1. tray_sim.py +10 -4
tray_sim.py CHANGED
@@ -189,7 +189,8 @@ def run_tray_simulation(
189
  num_objects=N_OBJECTS,
190
  azimuth=45,
191
  elevation=-25,
192
- distance=0.6
 
193
  ):
194
  np.random.seed(seed)
195
  model = mujoco.MjModel.from_xml_path(MODEL_PATH)
@@ -286,7 +287,8 @@ def run_tray_simulation(
286
  img = renderer.render()
287
 
288
  if t in keyframes:
289
- imageio.imwrite(f"/tmp/frame_{t}.png", img)
 
290
 
291
  frames.append(img)
292
 
@@ -319,7 +321,9 @@ def run_tray_simulation(
319
  }
320
 
321
  # Save JSON Snapshot (optional, for LLM input/debugging)
322
- json_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}_state.json")
 
 
323
  with open(json_path, "w") as f:
324
  json.dump(physics_state, f, indent=2)
325
 
@@ -331,7 +335,9 @@ def run_tray_simulation(
331
  )
332
 
333
  # Save to GIF
334
- gif_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}.gif")
 
 
335
  imageio.mimsave(gif_path, frames, fps=20)
336
 
337
  return gif_path, stability_flags, physics_state, prompt, json_path # optionally also return json_path
 
189
  num_objects=N_OBJECTS,
190
  azimuth=45,
191
  elevation=-25,
192
+ distance=0.6,
193
+ unique_id=None # Unique file naming
194
  ):
195
  np.random.seed(seed)
196
  model = mujoco.MjModel.from_xml_path(MODEL_PATH)
 
287
  img = renderer.render()
288
 
289
  if t in keyframes:
290
+ #imageio.imwrite(f"/tmp/frame_{t}.png", img)
291
+ imageio.imwrite(f"/tmp/frame_{t}_{unique_id}.png", img)
292
 
293
  frames.append(img)
294
 
 
321
  }
322
 
323
  # Save JSON Snapshot (optional, for LLM input/debugging)
324
+ #json_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}_state.json")
325
+ # Save JSON with unique ID
326
+ json_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{unique_id}_state.json")
327
  with open(json_path, "w") as f:
328
  json.dump(physics_state, f, indent=2)
329
 
 
335
  )
336
 
337
  # Save to GIF
338
+ #gif_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}.gif")
339
+ # Save GIF with unique ID
340
+ gif_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{unique_id}.gif")
341
  imageio.mimsave(gif_path, frames, fps=20)
342
 
343
  return gif_path, stability_flags, physics_state, prompt, json_path # optionally also return json_path