Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to mujoco composite object considering the geom element inside composite does not have "name" attribute #620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions robosuite/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __init__(self, fname):
self.tendon = self.create_default_element("tendon")
self.equality = self.create_default_element("equality")
self.contact = self.create_default_element("contact")
self.extension = self.create_default_element("extension")
self.compiler = self.create_default_element("compiler")

# Parse any default classes and replace them inline
default = self.create_default_element("default")
Expand Down
21 changes: 11 additions & 10 deletions robosuite/models/objects/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,17 @@ def _should_keep(el):
if not _should_keep(element):
parent.remove(element)
else:
g_name = element.get("name")
g_name = g_name if g_name is not None else f"g{i}"
element.set("name", g_name)
# Also optionally duplicate collision geoms if requested (and this is a collision geom)
if self.duplicate_collision_geoms and element.get("group") in {None, "0"}:
parent.append(self._duplicate_visual_from_collision(element))
# Also manually set the visual appearances to the original collision model
element.set("rgba", array_to_string(OBJECT_COLLISION_COLOR))
if element.get("material") is not None:
del element.attrib["material"]
if parent.tag!="composite":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mengqlTHU! Could you please run pre-commit run --all-files to format?

g_name = element.get("name")
g_name = g_name if g_name is not None else f"g{i}"
element.set("name", g_name)
# Also optionally duplicate collision geoms if requested (and this is a collision geom)
if self.duplicate_collision_geoms and element.get("group") in {None, "0"}:
parent.append(self._duplicate_visual_from_collision(element))
# Also manually set the visual appearances to the original collision model
element.set("rgba", array_to_string(OBJECT_COLLISION_COLOR))
if element.get("material") is not None:
del element.attrib["material"]
# add joint(s)
for joint_spec in self.joint_specs:
obj.append(new_joint(**joint_spec))
Expand Down
2 changes: 2 additions & 0 deletions robosuite/utils/mjcf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def _element_filter(element, parent):
# Check for actuator first since this is dependent on the parent element
if parent is not None and parent.tag == "actuator":
return "actuators"
elif parent is not None and parent.tag == "composite":
return "composite_geoms"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and could you please add "composite_geoms" to the doc string above?

elif element.tag == "joint":
# Make sure this is not a tendon (this should not have a "joint", "joint1", or "joint2" attribute specified)
if element.get("joint") is None and element.get("joint1") is None:
Expand Down
Loading