From 28c07f56c5365132fb8f583a63267e43887fdcae Mon Sep 17 00:00:00 2001 From: Abhishek Joshi Date: Wed, 18 Sep 2024 23:05:51 -0400 Subject: [PATCH 1/3] Adding documentation for USD exporter --- doc/index.rst | 1 + doc/usd.rst | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 doc/usd.rst diff --git a/doc/index.rst b/doc/index.rst index 0aba3e4c..56749bff 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -16,6 +16,7 @@ python MJX unity + usd models changelog diff --git a/doc/usd.rst b/doc/usd.rst new file mode 100644 index 00000000..d029c038 --- /dev/null +++ b/doc/usd.rst @@ -0,0 +1,92 @@ +============ +USD Exporter +============ + +Introduction +------------ + +The MuJoCo `USD exporter `_ allows users to save scenes and trajectories in USD format for rendering in external renderers such as NVIDIA Omniverse or Blender. These renderers provide higher quality rendering capabilities not provided with MuJoCo's default renderer. Some of these capabilities include real time ray tracing and and path tracing. Additionally, exporting to USD allows users to include different types of texture maps to make objects in the scene look more realistic. + +.. _USDInstallation: + +Installation instructions +------------------------- + +The recommended way to install the necessary requirements for the USD exporter is via `PyPI `_: + +.. code-block:: shell + + pip install mujoco[usd] + +This installs the optional dependencies ``usd-core`` and ``pillow`` required by the USD exporter. If you are building from source, please ensure to `build the Python bindings `_. Then, using pip, install the required ``usd-core`` and ``pillow`` packages. + +.. _USDExporter: + +USDExporter +---------------- + +In order to export MuJoCo scenes to USD, use the ``mujoco.usd.exporter`` module. Specifically, ``USDExporter`` allows you save full trajectories from MuJoCo in addition to defining custom cameras and lights. The arguments to the USDExporter are the following: + +- ``model`` : an MjModel instance. The USD exporter reads relevant information from the model including details about cameras, lights, textures, and object geometries to name a few. + +- ``max_geom`` : defines the maximum number of geoms in a scene. This argument is only used when create an MuJoCo scene. Please refer to `mjvScene `_ for more details. + +- ``output_directory_name`` : defines the name of the directory under which the exported USD file and all relevant assets are stored. When saving a scene/trajectory as a USD file, the exporter creates the following directory structure. + + .. code-block:: text + + output_directory_root/ + └-output_directory_name/ + ├-assets/ + | ├-texture_0.png + | ├-texture_1.png + | └-... + └─frames/ + └-frame_301.usd + + Using this file structure allows users to easily zip the directory ``output_directory_name`` and share it with other machines. All paths to assets in the USD file are relative paths. Thus, even if unzipped and rendered on another machine, the USD file still has access to the necessary assets. This is especially important when rendering offline on a server. + +- ``output_directory_root`` : defines the root directory to add USD trajectory to. + +- ``light_intensity`` : intensity of the lights in the renderer. Note that intensity may be defined differently in different renderers. As such, it might be valuable to set the value for light intensity based on your renderer of choice. + +- ``camera_names`` : a list of cameras to be stored in the USD file. At each time step, for each camera defined, we calculate its position and orientation and add that value for that given frame in the USD. USD allows us to store multiple cameras. However, when rendering, we typically only render with a singular camera at a time. + +- ``verbose`` : decides whether or not to print updates of the exporter. + +If you wish to export a MuJoCo model loaded directly from an MJCF, we provide a `demo `_ file in the ``usd`` directory of the repository to do so. This demo file also serves as a good example to how to use the USD export functionality. + +.. _USDBasicUsage: + +Basic usage +----------- + +Once the optional dependencies are installed, the USD exporter can be imported via ``from mujoco.usd import exporter``. + +``USDExporter`` handles all logic related to creating USD files. When instantiated, it will create the necessary output directories along with all the textures used by the model. In order to make an update to the USD trajectory, call the `update_scene` function. We describe the interface for this function in the USD Export API section of this page. Updating the scene updates all geoms, lights, and cameras in the scene with their pose. Additionally, we account for visibility of the geom. We store these updates for a specific frame. We maintain an interal counter of the number of times `update_scene` is called. This internal counter serves as a reference for the current frame. This means that you can step through the MuJoCo simulation for multiple time steps before updating the USD scene. Only when we call `update_scene` do we store any values in our USD file. + +.. _USDExportAPI: + +USD Export API +-------------- + +- ``update_scene(self, data, scene_option)`` : updates the scene with the latest simulation data passed in by the user. This function updates the geom, cameras, and lights in the scene. + +- ``add_light(self, pos, intensity, radius, color, obj_name, light_type)`` : adds a light to the USD scene with the given properties post hoc. + +- ``add_camera(self, pos, rotation_xyz, obj_name)`` : adds a camera to the USD scene with the given properties post hoc. + +- ``save_scene(self, filetype)`` : exports the USD scene using one of the usd filetype extensions .usd, .usda, or .usdc + +.. _USDTodos: + +TODOs +----- + +In this section, we list remaining action items for the USD exporter. Please feel free to suggest additional requests by creating a new `feature request `_ in the GitHub repository. + +- Add support for additional texture maps including metallic, occlusion, roughness, bump, etc. + +- Add support for online rendering with Isaac. + +- Add support for custom cameras \ No newline at end of file From 43bf8d5e1024a93d051c5336e6b61d86ab7fad23 Mon Sep 17 00:00:00 2001 From: Abhishek Joshi Date: Thu, 19 Sep 2024 07:42:30 -0400 Subject: [PATCH 2/3] Moving USD documentation under Python page --- .gitignore | 1 + doc/index.rst | 1 - doc/python.rst | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/usd.rst | 92 -------------------------------------------------- 4 files changed, 90 insertions(+), 93 deletions(-) delete mode 100644 doc/usd.rst diff --git a/.gitignore b/.gitignore index c924037f..699ccd14 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ build/ build_cmake/ python/dist/ +doc/_build # Exclude macOS folder attributes .DS_Store diff --git a/doc/index.rst b/doc/index.rst index 56749bff..0aba3e4c 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -16,7 +16,6 @@ python MJX unity - usd models changelog diff --git a/doc/python.rst b/doc/python.rst index 2454c075..8cfc3bca 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -708,3 +708,92 @@ non-exhaustive list of specific mujoco-py features: that mujoco-py’s implementation has a convenient extra feature, whereby the pose (as determined by ``sim.data``’s state) is transformed to a keyframe that’s added to the model before saving. This extra feature is not currently available in ``mujoco``. + +USD Exporter +============ + +The MuJoCo `USD exporter `_ allows users to save scenes and trajectories in USD format for rendering in external renderers such as NVIDIA Omniverse or Blender. These renderers provide higher quality rendering capabilities not provided with MuJoCo's default renderer. Some of these capabilities include real time ray tracing and and path tracing. Additionally, exporting to USD allows users to include different types of texture maps to make objects in the scene look more realistic. + +.. _USDInstallation: + +Installation instructions +------------------------- + +The recommended way to install the necessary requirements for the USD exporter is via `PyPI `_: + +.. code-block:: shell + + pip install mujoco[usd] + +This installs the optional dependencies ``usd-core`` and ``pillow`` required by the USD exporter. If you are building from source, please ensure to `build the Python bindings `_. Then, using pip, install the required ``usd-core`` and ``pillow`` packages. + +.. _USDExporter: + +USDExporter +---------------- + +In order to export MuJoCo scenes to USD, use the ``mujoco.usd.exporter`` module. Specifically, ``USDExporter`` allows you save full trajectories from MuJoCo in addition to defining custom cameras and lights. The arguments to the USDExporter are the following: + +- ``model`` : an MjModel instance. The USD exporter reads relevant information from the model including details about cameras, lights, textures, and object geometries to name a few. + +- ``max_geom`` : defines the maximum number of geoms in a scene. This argument is only used when create an MuJoCo scene. Please refer to `mjvScene `_ for more details. + +- ``output_directory_name`` : defines the name of the directory under which the exported USD file and all relevant assets are stored. When saving a scene/trajectory as a USD file, the exporter creates the following directory structure. + + .. code-block:: text + + output_directory_root/ + └-output_directory_name/ + ├-assets/ + | ├-texture_0.png + | ├-texture_1.png + | └-... + └─frames/ + └-frame_301.usd + + Using this file structure allows users to easily zip the directory ``output_directory_name`` and share it with other machines. All paths to assets in the USD file are relative paths. Thus, even if unzipped and rendered on another machine, the USD file still has access to the necessary assets. This is especially important when rendering offline on a server. + +- ``output_directory_root`` : defines the root directory to add USD trajectory to. + +- ``light_intensity`` : intensity of the lights in the renderer. Note that intensity may be defined differently in different renderers. As such, it might be valuable to set the value for light intensity based on your renderer of choice. + +- ``camera_names`` : a list of cameras to be stored in the USD file. At each time step, for each camera defined, we calculate its position and orientation and add that value for that given frame in the USD. USD allows us to store multiple cameras. However, when rendering, we typically only render with a singular camera at a time. + +- ``verbose`` : decides whether or not to print updates of the exporter. + +If you wish to export a MuJoCo model loaded directly from an MJCF, we provide a `demo `_ file in the ``usd`` directory of the repository to do so. This demo file also serves as a good example to how to use the USD export functionality. + +.. _USDBasicUsage: + +Basic usage +----------- + +Once the optional dependencies are installed, the USD exporter can be imported via ``from mujoco.usd import exporter``. + +``USDExporter`` handles all logic related to creating USD files. When instantiated, it will create the necessary output directories along with all the textures used by the model. In order to make an update to the USD trajectory, call the `update_scene` function. We describe the interface for this function in the USD Export API section of this page. Updating the scene updates all geoms, lights, and cameras in the scene with their pose. Additionally, we account for visibility of the geom. We store these updates for a specific frame. We maintain an interal counter of the number of times `update_scene` is called. This internal counter serves as a reference for the current frame. This means that you can step through the MuJoCo simulation for multiple time steps before updating the USD scene. Only when we call `update_scene` do we store any values in our USD file. + +.. _USDExportAPI: + +USD Export API +-------------- + +- ``update_scene(self, data, scene_option)`` : updates the scene with the latest simulation data passed in by the user. This function updates the geom, cameras, and lights in the scene. + +- ``add_light(self, pos, intensity, radius, color, obj_name, light_type)`` : adds a light to the USD scene with the given properties post hoc. + +- ``add_camera(self, pos, rotation_xyz, obj_name)`` : adds a camera to the USD scene with the given properties post hoc. + +- ``save_scene(self, filetype)`` : exports the USD scene using one of the usd filetype extensions .usd, .usda, or .usdc + +.. _USDTodos: + +USD TODOs +--------- + +In this section, we list remaining action items for the USD exporter. Please feel free to suggest additional requests by creating a new `feature request `_ in the GitHub repository. + +- Add support for additional texture maps including metallic, occlusion, roughness, bump, etc. + +- Add support for online rendering with Isaac. + +- Add support for custom cameras \ No newline at end of file diff --git a/doc/usd.rst b/doc/usd.rst deleted file mode 100644 index d029c038..00000000 --- a/doc/usd.rst +++ /dev/null @@ -1,92 +0,0 @@ -============ -USD Exporter -============ - -Introduction ------------- - -The MuJoCo `USD exporter `_ allows users to save scenes and trajectories in USD format for rendering in external renderers such as NVIDIA Omniverse or Blender. These renderers provide higher quality rendering capabilities not provided with MuJoCo's default renderer. Some of these capabilities include real time ray tracing and and path tracing. Additionally, exporting to USD allows users to include different types of texture maps to make objects in the scene look more realistic. - -.. _USDInstallation: - -Installation instructions -------------------------- - -The recommended way to install the necessary requirements for the USD exporter is via `PyPI `_: - -.. code-block:: shell - - pip install mujoco[usd] - -This installs the optional dependencies ``usd-core`` and ``pillow`` required by the USD exporter. If you are building from source, please ensure to `build the Python bindings `_. Then, using pip, install the required ``usd-core`` and ``pillow`` packages. - -.. _USDExporter: - -USDExporter ----------------- - -In order to export MuJoCo scenes to USD, use the ``mujoco.usd.exporter`` module. Specifically, ``USDExporter`` allows you save full trajectories from MuJoCo in addition to defining custom cameras and lights. The arguments to the USDExporter are the following: - -- ``model`` : an MjModel instance. The USD exporter reads relevant information from the model including details about cameras, lights, textures, and object geometries to name a few. - -- ``max_geom`` : defines the maximum number of geoms in a scene. This argument is only used when create an MuJoCo scene. Please refer to `mjvScene `_ for more details. - -- ``output_directory_name`` : defines the name of the directory under which the exported USD file and all relevant assets are stored. When saving a scene/trajectory as a USD file, the exporter creates the following directory structure. - - .. code-block:: text - - output_directory_root/ - └-output_directory_name/ - ├-assets/ - | ├-texture_0.png - | ├-texture_1.png - | └-... - └─frames/ - └-frame_301.usd - - Using this file structure allows users to easily zip the directory ``output_directory_name`` and share it with other machines. All paths to assets in the USD file are relative paths. Thus, even if unzipped and rendered on another machine, the USD file still has access to the necessary assets. This is especially important when rendering offline on a server. - -- ``output_directory_root`` : defines the root directory to add USD trajectory to. - -- ``light_intensity`` : intensity of the lights in the renderer. Note that intensity may be defined differently in different renderers. As such, it might be valuable to set the value for light intensity based on your renderer of choice. - -- ``camera_names`` : a list of cameras to be stored in the USD file. At each time step, for each camera defined, we calculate its position and orientation and add that value for that given frame in the USD. USD allows us to store multiple cameras. However, when rendering, we typically only render with a singular camera at a time. - -- ``verbose`` : decides whether or not to print updates of the exporter. - -If you wish to export a MuJoCo model loaded directly from an MJCF, we provide a `demo `_ file in the ``usd`` directory of the repository to do so. This demo file also serves as a good example to how to use the USD export functionality. - -.. _USDBasicUsage: - -Basic usage ------------ - -Once the optional dependencies are installed, the USD exporter can be imported via ``from mujoco.usd import exporter``. - -``USDExporter`` handles all logic related to creating USD files. When instantiated, it will create the necessary output directories along with all the textures used by the model. In order to make an update to the USD trajectory, call the `update_scene` function. We describe the interface for this function in the USD Export API section of this page. Updating the scene updates all geoms, lights, and cameras in the scene with their pose. Additionally, we account for visibility of the geom. We store these updates for a specific frame. We maintain an interal counter of the number of times `update_scene` is called. This internal counter serves as a reference for the current frame. This means that you can step through the MuJoCo simulation for multiple time steps before updating the USD scene. Only when we call `update_scene` do we store any values in our USD file. - -.. _USDExportAPI: - -USD Export API --------------- - -- ``update_scene(self, data, scene_option)`` : updates the scene with the latest simulation data passed in by the user. This function updates the geom, cameras, and lights in the scene. - -- ``add_light(self, pos, intensity, radius, color, obj_name, light_type)`` : adds a light to the USD scene with the given properties post hoc. - -- ``add_camera(self, pos, rotation_xyz, obj_name)`` : adds a camera to the USD scene with the given properties post hoc. - -- ``save_scene(self, filetype)`` : exports the USD scene using one of the usd filetype extensions .usd, .usda, or .usdc - -.. _USDTodos: - -TODOs ------ - -In this section, we list remaining action items for the USD exporter. Please feel free to suggest additional requests by creating a new `feature request `_ in the GitHub repository. - -- Add support for additional texture maps including metallic, occlusion, roughness, bump, etc. - -- Add support for online rendering with Isaac. - -- Add support for custom cameras \ No newline at end of file From 456dcc150c6419bb04567e8c25c5aa064a547c10 Mon Sep 17 00:00:00 2001 From: Abhishek Joshi Date: Mon, 23 Sep 2024 14:10:48 -0400 Subject: [PATCH 3/3] Updating documentation for comments --- doc/python.rst | 118 ++++++++++++++++++++++------- python/mujoco/usd/exporter.py | 10 +-- python/mujoco/usd/exporter_test.py | 2 +- 3 files changed, 98 insertions(+), 32 deletions(-) diff --git a/doc/python.rst b/doc/python.rst index 8cfc3bca..afc24e2c 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -712,88 +712,154 @@ non-exhaustive list of specific mujoco-py features: USD Exporter ============ -The MuJoCo `USD exporter `_ allows users to save scenes and trajectories in USD format for rendering in external renderers such as NVIDIA Omniverse or Blender. These renderers provide higher quality rendering capabilities not provided with MuJoCo's default renderer. Some of these capabilities include real time ray tracing and and path tracing. Additionally, exporting to USD allows users to include different types of texture maps to make objects in the scene look more realistic. +The `USD exporter `_ allows users to save +scenes and trajectories in USD format for rendering in external renderers such as NVIDIA Omniverse or Blender. These +renderers provide higher quality rendering capabilities not provided with the default renderer. Some of these +capabilities include real time ray tracing and and path tracing. Additionally, exporting to USD allows users to include +different types of texture maps to make objects in the scene look more realistic. .. _USDInstallation: Installation instructions ------------------------- -The recommended way to install the necessary requirements for the USD exporter is via `PyPI `_: +The recommended way to install the necessary requirements for the USD exporter is via +`PyPI `_: .. code-block:: shell pip install mujoco[usd] -This installs the optional dependencies ``usd-core`` and ``pillow`` required by the USD exporter. If you are building from source, please ensure to `build the Python bindings `_. Then, using pip, install the required ``usd-core`` and ``pillow`` packages. +This installs the optional dependencies ``usd-core`` and ``pillow`` required by the USD exporter. If you are building +from source, please ensure to +`build the Python bindings `_. +Then, using pip, install the required ``usd-core`` and ``pillow`` packages. .. _USDExporter: USDExporter ----------------- +----------- -In order to export MuJoCo scenes to USD, use the ``mujoco.usd.exporter`` module. Specifically, ``USDExporter`` allows you save full trajectories from MuJoCo in addition to defining custom cameras and lights. The arguments to the USDExporter are the following: +In order to export scenes to USD, use the ``mujoco.usd.exporter`` module. Specifically, ``USDExporter`` allows +you save full trajectories in addition to defining custom cameras and lights. The arguments to the +USDExporter are the following: -- ``model`` : an MjModel instance. The USD exporter reads relevant information from the model including details about cameras, lights, textures, and object geometries to name a few. +- ``model`` : an MjModel instance. The USD exporter reads relevant information from the model including details about + cameras, lights, textures, and object geometries to name a few. -- ``max_geom`` : defines the maximum number of geoms in a scene. This argument is only used when create an MuJoCo scene. Please refer to `mjvScene `_ for more details. +- ``max_geom`` : defines the maximum number of geoms in a scene. This argument is only used when creating a scene. + Please refer to `mjvScene `_ for + more details. -- ``output_directory_name`` : defines the name of the directory under which the exported USD file and all relevant assets are stored. When saving a scene/trajectory as a USD file, the exporter creates the following directory structure. +- ``output_directory`` : defines the name of the directory under which the exported USD file and all relevant + assets are stored. When saving a scene/trajectory as a USD file, the exporter creates the following directory + structure. .. code-block:: text output_directory_root/ - └-output_directory_name/ - ├-assets/ - | ├-texture_0.png - | ├-texture_1.png - | └-... - └─frames/ + └-output_directory/ + ├-assets/ + | ├-texture_0.png + | ├-texture_1.png + | └-... + └─frames/ └-frame_301.usd - Using this file structure allows users to easily zip the directory ``output_directory_name`` and share it with other machines. All paths to assets in the USD file are relative paths. Thus, even if unzipped and rendered on another machine, the USD file still has access to the necessary assets. This is especially important when rendering offline on a server. + Using this file structure allows users to easily zip the directory ``output_directory`` and share it with other + machines. All paths to assets in the USD file are relative paths. Thus, even if unzipped and rendered on another + machine, the USD file still has access to the necessary assets. This is especially important when rendering offline + on a server. - ``output_directory_root`` : defines the root directory to add USD trajectory to. -- ``light_intensity`` : intensity of the lights in the renderer. Note that intensity may be defined differently in different renderers. As such, it might be valuable to set the value for light intensity based on your renderer of choice. +- ``light_intensity`` : intensity of the lights in the renderer. Note that intensity may be defined differently in + different renderers. As such, it might be valuable to set the value for light intensity based on your renderer of + choice. -- ``camera_names`` : a list of cameras to be stored in the USD file. At each time step, for each camera defined, we calculate its position and orientation and add that value for that given frame in the USD. USD allows us to store multiple cameras. However, when rendering, we typically only render with a singular camera at a time. +- ``camera_names`` : a list of cameras to be stored in the USD file. At each time step, for each camera defined, we + calculate its position and orientation and add that value for that given frame in the USD. USD allows us to store + multiple cameras. However, when rendering, we typically only render with a singular camera at a time. - ``verbose`` : decides whether or not to print updates of the exporter. -If you wish to export a MuJoCo model loaded directly from an MJCF, we provide a `demo `_ file in the ``usd`` directory of the repository to do so. This demo file also serves as a good example to how to use the USD export functionality. +If you wish to export a model loaded directly from an MJCF, we provide a +`demo `_ file in the ``usd`` directory of +the repository to do so. This demo file also serves as a good example to how to use the USD export functionality. .. _USDBasicUsage: Basic usage ----------- -Once the optional dependencies are installed, the USD exporter can be imported via ``from mujoco.usd import exporter``. +Once the optional dependencies are installed, the USD exporter can be imported via ``from mujoco.usd import exporter``. -``USDExporter`` handles all logic related to creating USD files. When instantiated, it will create the necessary output directories along with all the textures used by the model. In order to make an update to the USD trajectory, call the `update_scene` function. We describe the interface for this function in the USD Export API section of this page. Updating the scene updates all geoms, lights, and cameras in the scene with their pose. Additionally, we account for visibility of the geom. We store these updates for a specific frame. We maintain an interal counter of the number of times `update_scene` is called. This internal counter serves as a reference for the current frame. This means that you can step through the MuJoCo simulation for multiple time steps before updating the USD scene. Only when we call `update_scene` do we store any values in our USD file. +Below, we demonstrate a simple example of using the ``USDExporter``. During initialization, the ``USDExporter`` creates +an empty USD stage, as well as the assets and frames directories if they do not already exist. Additionally, it +generates .png files for each texture defined in the model. Every time ``update_scene`` is called, the exporter records +the position and orientation of all geoms, lights, and cameras in the scene. +The ``USDExporter`` keeps track of frames internally by maintaining a frame counter. Each time ``update_scene`` is +called, the counter is incremented, and the poses of all geoms, cameras, and lights are saved for the corresponding +frame. It's important to note that you can step through the simulation multiple times before calling ``update_scene``. +The final USD file will only store the poses of the geoms, lights, and cameras as they were at the last update_scene +call. + +.. code-block:: python + + import mujoco + from mujoco.usd import exporter + + m = mujoco.MjModel.from_xml_path('/path/to/mjcf.xml') + d = mujoco.MjData(m) + + # Create the USDExporter + exp = exporter.USDExporter(model=m) + + duration = 5 + framerate = 60 + while d.time < duration: + + # Step the physics + mujoco.mj_step(m, d) + + if exp.frame_count < d.time * framerate: + # Update the USD with a new frame + exp.update_scene(data=d) + + # Export the USD file + exp.save_scene(filetype="usd") + + + .. _USDExportAPI: USD Export API -------------- -- ``update_scene(self, data, scene_option)`` : updates the scene with the latest simulation data passed in by the user. This function updates the geom, cameras, and lights in the scene. +- ``update_scene(self, data, scene_option)`` : updates the scene with the latest simulation data passed in by the + user. This function updates the geom, cameras, and lights in the scene. -- ``add_light(self, pos, intensity, radius, color, obj_name, light_type)`` : adds a light to the USD scene with the given properties post hoc. +- ``add_light(self, pos, intensity, radius, color, obj_name, light_type)`` : adds a light to the USD scene with the + given properties post hoc. -- ``add_camera(self, pos, rotation_xyz, obj_name)`` : adds a camera to the USD scene with the given properties post hoc. +- ``add_camera(self, pos, rotation_xyz, obj_name)`` : adds a camera to the USD scene with the given properties post + hoc. -- ``save_scene(self, filetype)`` : exports the USD scene using one of the usd filetype extensions .usd, .usda, or .usdc +- ``save_scene(self, filetype)`` : exports the USD scene using one of the usd filetype extensions .usd, .usda, or + .usdc .. _USDTodos: USD TODOs --------- -In this section, we list remaining action items for the USD exporter. Please feel free to suggest additional requests by creating a new `feature request `_ in the GitHub repository. +In this section, we list remaining action items for the USD exporter. Please feel free to suggest additional requests +by creating a new `feature request `_ in the GitHub +repository. - Add support for additional texture maps including metallic, occlusion, roughness, bump, etc. - Add support for online rendering with Isaac. -- Add support for custom cameras \ No newline at end of file +- Add support for custom cameras diff --git a/python/mujoco/usd/exporter.py b/python/mujoco/usd/exporter.py index d0f4f8a1..b8af04ad 100644 --- a/python/mujoco/usd/exporter.py +++ b/python/mujoco/usd/exporter.py @@ -42,7 +42,7 @@ class USDExporter: height: int = 480, width: int = 480, max_geom: int = 10000, - output_directory_name: str = "mujoco_usdpkg", + output_directory: str = "mujoco_usdpkg", output_directory_root: str = "./", light_intensity: int = 10000, camera_names: Optional[List[str]] = None, @@ -59,7 +59,7 @@ class USDExporter: can be rendered in the same scene. If None this will be chosen automatically based on the estimated maximum number of renderable geoms in the model. - output_directory_name: name of root directory to store outputted frames + output_directory: name of root directory to store outputted frames and assets generated by the USD renderer. output_directory_root: path to root directory storing generated frames and assets by the USD renderer. @@ -95,7 +95,7 @@ class USDExporter: self.height = height self.width = width self.max_geom = max_geom - self.output_directory_name = output_directory_name + self.output_directory = output_directory self.output_directory_root = output_directory_root self.light_intensity = light_intensity self.camera_names = camera_names @@ -149,7 +149,7 @@ class USDExporter: def _initialize_output_directories(self): """Initializes output directories to store frames and assets.""" self.output_directory_path = os.path.join( - self.output_directory_root, self.output_directory_name + self.output_directory_root, self.output_directory ) if not os.path.exists(self.output_directory_path): os.makedirs(self.output_directory_path) @@ -498,7 +498,7 @@ class USDExporter: geom_ref.update_visibility(False, geom_ref.last_visible_frame+1) self.stage.Export( - f"{self.output_directory_root}/{self.output_directory_name}/" + + f"{self.output_directory_root}/{self.output_directory}/" + f"frames/frame_{self.frame_count}.{filetype}" ) if self.verbose: diff --git a/python/mujoco/usd/exporter_test.py b/python/mujoco/usd/exporter_test.py index 321593a7..c80ae11d 100644 --- a/python/mujoco/usd/exporter_test.py +++ b/python/mujoco/usd/exporter_test.py @@ -43,7 +43,7 @@ class ExporterTest(absltest.TestCase): data = mujoco.MjData(model) exporter = exporter_module.USDExporter( model, - output_directory_name=output_dir_name, + output_directory=output_dir_name, output_directory_root=output_dir_root, camera_names=["closeup"], )