File size: 4,431 Bytes
2fbee2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/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")