Created
August 9, 2025 18:41
-
-
Save yunho-c/42622ba7f7623e240cd560fbaa1321f9 to your computer and use it in GitHub Desktop.
Convert URDF to MJCF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import mujoco | |
| from pathlib import Path | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Convert a URDF file to a MuJoCo XML file.") | |
| parser.add_argument("input_file", help="The input URDF file path.") | |
| # parser.add_argument("output_file", help="The output XML file path.") | |
| args = parser.parse_args() | |
| model = mujoco.MjModel.from_xml_path(args.input_file) | |
| # mujoco.mj_saveLastXML(args.output_file, model) | |
| mujoco.mj_saveLastXML(args.input_file.replace(".urdf", ".xml"), model) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment