-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_virtual_constraint_plotter.py
More file actions
54 lines (42 loc) · 1.92 KB
/
batch_virtual_constraint_plotter.py
File metadata and controls
54 lines (42 loc) · 1.92 KB
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
#!/usr/bin/env python3
"""Batch script to run virtual_constraint_plotter.py on all gait library solutions."""
import os
import subprocess
import glob
def main():
# Configuration
gait_lib_dir = "results/gait_lib"
config_path = "configs/single_support_config.yaml"
# Find all result directories
result_dirs = glob.glob(os.path.join(gait_lib_dir, "result_*"))
result_dirs.sort() # Sort to process in order
print(f"Found {len(result_dirs)} gait library results to process")
for result_dir in result_dirs:
# Extract velocity from directory name (e.g., "result_9" -> "9")
velocity = os.path.basename(result_dir).replace("result_", "")
# Find the solution file
solution_file = os.path.join(result_dir, f"single_support_config_solution_{velocity}.yaml")
if not os.path.exists(solution_file):
print(f"Warning: Solution file not found: {solution_file}")
continue
print(f"\nProcessing velocity {velocity} cm/s...")
print(f"Solution file: {solution_file}")
print(f"Output directory: {result_dir}")
# Call virtual_constraint_plotter.py
cmd = [
"python", "virtual_constraint_plotter.py",
"--yaml-path", solution_file,
"--config-path", config_path,
"--output-dir", result_dir
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
print(f"✓ Successfully processed velocity {velocity} cm/s")
except subprocess.CalledProcessError as e:
print(f"✗ Error processing velocity {velocity} cm/s:")
print(f" Error: {e}")
print(f" stdout: {e.stdout}")
print(f" stderr: {e.stderr}")
print(f"\nBatch processing complete! Processed {len(result_dirs)} gait library results.")
if __name__ == "__main__":
main()