Skip to content

Commit

Permalink
Update MjcfExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
HoangGiang93 committed Aug 20, 2024
1 parent 0557d9c commit 0f9933b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ def _build_config(self):

default = ET.SubElement(self.root, "default")
default_visual = ET.SubElement(default, "default")
default_visual.set("class", "visual")
default_visual.set("class", f"{self.factory.config.model_name}_visual")
default_visual_geom = ET.SubElement(default_visual, "geom")
default_visual_geom.set("contype", "0")
default_visual_geom.set("conaffinity", "0")

default_collision = ET.SubElement(default, "default")
default_collision.set("class", "collision")
default_collision.set("class", f"{self.factory.config.model_name}_collision")
default_collision_geom = ET.SubElement(default_collision, "geom")
default_collision_geom.set(
"rgba",
Expand Down Expand Up @@ -496,6 +496,8 @@ def _build_body(self, body_name: str, parent_body_name: str) -> None:
else:
if parent_body_name == "worldbody":
mujoco_body_api = get_mujoco_body_api(xform_prim=xform_prim)
if not self.factory.config.fixed_base and self.factory.config.with_physics:
ET.SubElement(body, "freejoint")
else:
parent_body_builder = world_builder.get_body_builder(parent_body_name)
parent_xform_prim = parent_body_builder.xform.GetPrim()
Expand Down Expand Up @@ -546,9 +548,9 @@ def _build_geom(self, geom_builder: GeomBuilder, body: ET.Element) -> None:
geom.set("rgba", " ".join(map(str, rgba)))

if gprim_prim.GetPrim().HasAPI(UsdPhysics.CollisionAPI):
geom.set("class", "collision")
geom.set("class", f"{self.factory.config.model_name}_collision")
else:
geom.set("class", "visual")
geom.set("class", f"{self.factory.config.model_name}_visual")

def _build_composite(self, points_builder: PointsBuilder, body: ET.Element) -> None:
mujoco_composite_api = get_mujoco_composite_api(points_builder=points_builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def import_mesh(self,
process = subprocess.Popen(cmd)
process.wait()

if mesh_file_path == self.source_file_path:
if mesh_file_path == self.source_file_path and os.path.exists(mesh_file_path_clone):
os.remove(mesh_file_path_clone)

fix_texture_path(usd_mesh_file_path=tmp_usd_mesh_file_path)
Expand Down

0 comments on commit 0f9933b

Please sign in to comment.