File size: 1,394 Bytes
a65dde2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from tqdm import tqdm
import numpy as np

data_root = "/home/thomas/dev/isaac_projects/AMASS_Retargeted_for_G1/g1"

def check_dof_positions_in_npz(root_folder):
    """
    Recursively walk through 'root_folder', find each .npz file, and check whether
    'dof_positions' values are all within [-π, π]. Log violations.
    """
    files_to_process = []
    for dirpath, _, filenames in os.walk(root_folder):
        for filename in filenames:
            if filename.endswith(".npz"):
                files_to_process.append(os.path.join(dirpath, filename))

    violating_files = []

    for npz_path in tqdm(files_to_process, desc="Checking files for [-π, π] bounds"):
        try:
            data = np.load(npz_path)
            data_dict = dict(data)
        except Exception as e:
            print(f"Error loading {npz_path}: {e}")
            continue

        if "dof_positions" in data_dict:
            dof_positions = data_dict["dof_positions"]
            if not np.all((dof_positions >= -np.pi) & (dof_positions <= np.pi)):
                violating_files.append(npz_path)

    if violating_files:
        print("\nFiles with 'dof_positions' outside [-π, π]:")
        for file in violating_files:
            print(file)
    else:
        print("\n✅ All files are within [-π, π] bounds.")

if __name__ == "__main__":
    check_dof_positions_in_npz(data_root)