adding support for unnamed geoms
This commit is contained in:
@@ -6,7 +6,7 @@ import exporter
|
||||
if __name__ == "__main__":
|
||||
|
||||
# load a model to mujoco
|
||||
m = mujoco.MjModel.from_xml_path("/Users/abhishek/Documents/research/mujoco/model/humanoid/humanoid.xml")
|
||||
m = mujoco.MjModel.from_xml_path("/Users/abhishek/Documents/research/mujoco/test/engine/testdata/catenary.xml")
|
||||
d = mujoco.MjData(m)
|
||||
|
||||
# create an instance of the USDExporter
|
||||
|
||||
@@ -235,6 +235,9 @@ class USDExporter:
|
||||
def _load_geom(self, geom: mujoco.MjvGeom):
|
||||
|
||||
geom_name = mujoco.mj_id2name(self.model, geom.objtype, geom.objid)
|
||||
if not geom_name:
|
||||
geom_name = f"unnamed_geom{geom.objid}"
|
||||
|
||||
assert geom_name not in self.geom_name2usd
|
||||
|
||||
texture_file = self.texture_files[geom.texid] if geom.texid != -1 else None
|
||||
@@ -250,13 +253,11 @@ class USDExporter:
|
||||
texture_file=texture_file,
|
||||
)
|
||||
else:
|
||||
|
||||
mesh_config = shapes_module.mesh_config_generator(
|
||||
name=geom_name,
|
||||
geom_type=geom.type,
|
||||
size=geom.size
|
||||
)
|
||||
|
||||
usd_geom = component_module.USDPrimitiveMesh(
|
||||
mesh_config=mesh_config,
|
||||
stage=self.stage,
|
||||
@@ -276,6 +277,8 @@ class USDExporter:
|
||||
for i in range(self.scene.ngeom):
|
||||
geom = self.scene.geoms[i]
|
||||
geom_name = mujoco.mj_id2name(self.model, geom.objtype, geom.objid)
|
||||
if not geom_name:
|
||||
geom_name = f"unnamed_geom{geom.objid}"
|
||||
|
||||
if geom_name not in self.geom_name2usd:
|
||||
self._load_geom(geom)
|
||||
|
||||
Reference in New Issue
Block a user