Fixing formatting for USD scripts

This commit is contained in:
Abhishek Joshi
2024-07-04 16:25:44 -05:00
parent fcb247e35b
commit e734527e7b
6 changed files with 18 additions and 42 deletions
+1 -2
View File
@@ -18,8 +18,7 @@ from pxr import Gf
from pxr import Usd
from pxr import UsdGeom
# import mujoco.usd.utils as utils_component
import utils as utils_component
import mujoco.usd.utils as utils_component
class USDCamera:
"""Class that handles the cameras in the USD scene"""
+8 -10
View File
@@ -1,14 +1,12 @@
import argparse
from tqdm import tqdm
from pathlib import Path
import mujoco
# from mujoco.usd import exporter
import exporter
from mujoco.usd import exporter
def generate_usd_trajectory(args):
"""Generates a USD file given the user arguments"""
# load a model to mujoco
model_path = args.model_path
m = mujoco.MjModel.from_xml_path(model_path)
@@ -19,7 +17,7 @@ def generate_usd_trajectory(args):
output_directory_name=Path(args.model_path).stem,
output_directory_root=args.output_directory_root,
camera_names=args.camera_names)
# step through the simulation for the given duration of time
while d.time < args.duration:
mujoco.mj_step(m, d)
@@ -32,7 +30,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--model_path',
parser.add_argument('--model_path',
type=str,
required=True,
help='path to mjcf xml model')
@@ -47,20 +45,20 @@ if __name__ == "__main__":
default=60,
help='frame rate of the generated video')
parser.add_argument('--output_directory_root',
parser.add_argument('--output_directory_root',
type=str,
default="../usd_trajectories/",
help='location where to create usd files')
parser.add_argument('--camera_names',
parser.add_argument('--camera_names',
type=str,
nargs='+',
help='cameras to include in usd')
parser.add_argument('--export_extension',
parser.add_argument('--export_extension',
type=str,
default="usd",
help='extension of exported file (can be usd, usda, or usdc)')
help='extension of exported file (usd, usda, usdc)')
args = parser.parse_args()
generate_usd_trajectory(args)
+5 -10
View File
@@ -29,15 +29,10 @@ from pxr import UsdGeom
import mujoco
# import mujoco.usd.shapes as shapes_module
# import mujoco.usd.objects as object_module
# import mujoco.usd.lights as light_module
# import mujoco.usd.camera as camera_module
import shapes as shapes_module
import objects as object_module
import lights as light_module
import camera as camera_module
import mujoco.usd.shapes as shapes_module
import mujoco.usd.objects as object_module
import mujoco.usd.lights as light_module
import mujoco.usd.camera as camera_module
class USDExporter:
"""MuJoCo to USD exporter for porting scenes to external renderers."""
@@ -248,7 +243,7 @@ class USDExporter:
assert geom_name not in self.geom_names
texture_file = (
self.texture_files[self.model.mat_texid[mujoco.mjNTEXMAT*geom.matid]]
self.texture_files[self.model.mat_texid[geom.matid][0]]
if geom.matid != -1
else None
)
+3 -18
View File
@@ -27,11 +27,8 @@ from pxr import Vt
import mujoco
# import mujoco.usd.utils as utils_component
# import mujoco.usd.shapes as shapes_component
import utils as utils_component
import shapes as shapes_component
import mujoco.usd.utils as utils_component
import mujoco.usd.shapes as shapes_component
class USDObject(ABC):
""" Abstract interface for all USD objects including meshes and primitives.
@@ -366,21 +363,9 @@ class USDPrimitiveMesh(USDObject):
def _get_uv_geometry(self):
assert self.prim_mesh
x_scale, y_scale = self.geom.texrepeat
mesh_texcoord = np.array(self.prim_mesh.triangle_uvs)
mesh_facetexcoord = np.asarray(self.prim_mesh.triangles)
x_multiplier, y_multiplier = 1, 1
if self.geom.texuniform:
if "box" in self.mesh_config:
x_multiplier = self.mesh_config["box"]["width"]
y_multiplier = self.mesh_config["box"]["height"]
elif "sphere" in self.mesh_config:
x_multiplier = self.mesh_config["sphere"]["radius"]
y_multiplier = self.mesh_config["sphere"]["radius"]
mesh_texcoord[:, 0] *= x_scale * x_multiplier
mesh_texcoord[:, 1] *= y_scale * y_multiplier
# TODO(etom): bring back support for rescaling the texture coordinates.
return mesh_texcoord, mesh_facetexcoord.flatten()
+1 -1
View File
@@ -151,7 +151,7 @@ def mesh_generator(
prim_mesh, mesh = None, None
for shape, config in mesh_config.items():
if "name" in shape:
continue
-1
View File
@@ -14,7 +14,6 @@
# ==============================================================================
import numpy as np
def create_transform_matrix(rotation_matrix, translation_vector):
# Ensure rotation_matrix and translation_vector are NumPy arrays
rotation_matrix = np.array(rotation_matrix)