MCPcopy Create free account
hub / github.com/RoboVerseOrg/RoboVerse / process_folder

Function process_folder

scripts/conversion/batch_mjcf2urdf.py:17–53  ·  view source on GitHub ↗

Recursively process all MJCF/XML files in the given folder and its subfolders. Args: folder_path (str): Path to the folder containing MJCF/XML files Returns: list[ConversionResult]: List of conversion results

(folder_path)

Source from the content-addressed store, hash-verified

15
16
17def process_folder(folder_path):
18 """
19 Recursively process all MJCF/XML files in the given folder and its subfolders.
20
21 Args:
22 folder_path (str): Path to the folder containing MJCF/XML files
23
24 Returns:
25 list[ConversionResult]: List of conversion results
26 """
27 results = []
28 folder_path = Path(folder_path)
29
30 xml_files = list(folder_path.rglob("*.xml")) + list(folder_path.rglob("*.mjcf"))
31 xml_files.sort()
32
33 for input_file in xml_files:
34 result = ConversionResult(str(input_file), False)
35
36 try:
37 output_file = input_file.with_suffix(".urdf")
38 result.output_file = str(output_file)
39
40 output_file.parent.mkdir(parents=True, exist_ok=True)
41
42 mjcf_to_urdf(str(input_file), str(output_file))
43
44 result.success = True
45 print(f"Successfully converted: {input_file}")
46
47 except Exception as e:
48 result.error_msg = str(e)
49 print(f"Failed to convert {input_file}: {e!s}")
50
51 results.append(result)
52
53 return results
54
55
56def generate_log(results, folder_path):

Callers 1

mainFunction · 0.85

Calls 3

mjcf_to_urdfFunction · 0.90
ConversionResultClass · 0.85
printFunction · 0.85

Tested by

no test coverage detected