#!/usr/bin/env python3 """ Record trial videos with timestamps to avoid overriding existing files """ import os import time from datetime import datetime import main_orchestrator_enhanced def record_trial_videos(): """Run trial and record videos with unique timestamps""" # Create timestamp for this session timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") print(f"šŸŽ¬ Recording Trial Videos - Session: {timestamp}") print("=" * 60) # Ensure outputs directory exists os.makedirs("outputs", exist_ok=True) # List existing videos existing_videos = [f for f in os.listdir("outputs") if f.endswith('.gif')] print(f"šŸ“ Existing videos: {len(existing_videos)} files") for video in existing_videos[:5]: # Show first 5 print(f" • {video}") if len(existing_videos) > 5: print(f" • ... and {len(existing_videos) - 5} more") print(f"\nšŸš€ Starting Enhanced Trial with Video Recording...") print(f"šŸ“¹ New videos will be saved with timestamp: {timestamp}") try: # Test Robot Design print(f"\nšŸ¤– Testing Robot Design...") robot_success, robot_specs = main_orchestrator_enhanced.console_design_vehicle_for_obstacle( vehicle_type='robot', user_task_description=f'Design a robot that can pass the 5cm high obstacle - Session {timestamp}' ) print(f"āœ… Robot trial completed!") print(f" Success: {robot_success}") print(f" Final specs: {robot_specs}") # Test Drone Design print(f"\n🚁 Testing Drone Design...") drone_success, drone_specs = main_orchestrator_enhanced.console_design_vehicle_for_obstacle( vehicle_type='drone', user_task_description=f'Design a drone that can pass the 5cm high obstacle - Session {timestamp}' ) print(f"āœ… Drone trial completed!") print(f" Success: {drone_success}") print(f" Final specs: {drone_specs}") # List new videos created print(f"\nšŸ“¹ VIDEO RECORDING RESULTS:") new_videos = [f for f in os.listdir("outputs") if f.endswith('.gif')] new_count = len(new_videos) - len(existing_videos) print(f"Total videos now: {len(new_videos)} files (+{new_count} new)") # Show newest videos (those created in this session) newest_videos = sorted([f for f in new_videos if f not in existing_videos]) if newest_videos: print(f"\nšŸŽ¬ NEW VIDEOS CREATED:") for video in newest_videos: file_path = os.path.join("outputs", video) file_size = os.path.getsize(file_path) print(f" • {video} ({file_size:,} bytes)") # Check JSON files json_files = [f for f in os.listdir(".") if f.startswith("best_") and f.endswith(".json")] latest_json = sorted(json_files)[-2:] if len(json_files) >= 2 else json_files if latest_json: print(f"\nšŸ“„ LATEST JSON RESULTS:") for json_file in latest_json: print(f" • {json_file}") print(f"\nšŸŽÆ TRIAL SESSION {timestamp} COMPLETED SUCCESSFULLY!") print(f" Robot moved: {robot_success}") print(f" Drone moved: {drone_success}") print(f" Videos created: {new_count}") print(f" No existing videos were overridden āœ…") return { "timestamp": timestamp, "robot_success": robot_success, "drone_success": drone_success, "videos_created": new_count, "newest_videos": newest_videos } except Exception as e: print(f"āŒ Error during trial recording: {e}") import traceback traceback.print_exc() return None if __name__ == "__main__": result = record_trial_videos() if result: print(f"\nšŸ† FINAL SUMMARY:") print(f"Session: {result['timestamp']}") print(f"Robot performance: {'āœ… Success' if result['robot_success'] else 'āŒ Failed'}") print(f"Drone performance: {'āœ… Success' if result['drone_success'] else 'āŒ Failed'}") print(f"Videos recorded: {result['videos_created']}") print(f"All videos preserved! šŸŽ¬") else: print("āŒ Trial recording failed")