mani_skill.utils.building._mjcf_loader#
Loader code to import MJCF xml files into SAPIEN
Code partially adapted from NVIDIA/warp
Articulations are known as kinematic trees (defined by <body> tags) in Mujoco. A single .xml file can have multiple articulations
Any <geom> tag in <worldbody> but not a <body> tag will be built as separate static actors if possible. Actors that are not static seem to be defined with a free joint under a single body tag.
Warnings of unloadable tags/data can be printed if verbosity is turned on (by default it is off)
Notes
Joint properties relating to the solver, stiffness, actuator, are all not directly imported here and instead must be implemented via a controller like other robots in SAPIEN
Contact tags are not supported
Tendons/equality constraints are supported but may not work the same
The default group of geoms is 0 in mujoco. From docs it appears only group 0 and 2 are rendered by default. This is also by default what the visualizer shows and presumably what image renders show. Any other group is treated as being invisible (e.g. in SAPIEN we do not add visual bodies). SAPIEN does not currently support toggling render groups like Mujoco. Sometimes a MJCF might not follow this and will try and render other groups. In that case the loader supports indicating which other groups to add visual bodies for.
Ref: https://mujoco.readthedocs.io/en/stable/XMLreference.html#body-geom-group, https://mujoco.readthedocs.io/en/latest/modeling.html#composite-objects (says group 3 is turned off)
If contype is 0, it means that geom can’t collide with anything. We do this by not adding a collision shape at all.
geoms under worldbody but not body tags are treated as static objects at the moment.
Useful references: - Collision detection: https://mujoco.readthedocs.io/en/stable/computation/index.html#collision-detection
Attributes#
Classes#
Class to load MJCF into SAPIEN. |
|
Functions#
|
|
|
|
|
|
|
|
|
|
|
Module Contents#
- class mani_skill.utils.building._mjcf_loader.MJCFLoader(ignore_classes=['motor'], visual_groups=[0, 2])[source]#
Class to load MJCF into SAPIEN.
- _build_geom(geom, builder, defaults)[source]#
- Parameters:
geom (xml.etree.ElementTree.Element) –
builder (Union[sapien.wrapper.articulation_builder.LinkBuilder, sapien.ActorBuilder]) –
- _build_link(body, body_attrib, link_builder, defaults)[source]#
sets inertial, visual/collision shapes
- Parameters:
body (xml.etree.ElementTree.Element) –
link_builder (sapien.wrapper.articulation_builder.LinkBuilder) –
- _parse_body(body, parent, incoming_defaults, builder)[source]#
- Parameters:
body (xml.etree.ElementTree.Element) –
parent (sapien.wrapper.articulation_builder.LinkBuilder) –
incoming_defaults (dict) –
builder (sapien.wrapper.articulation_builder.ArticulationBuilder) –
- _parse_default(node, parent)[source]#
Parse a MJCF default attribute. https://mujoco.readthedocs.io/en/stable/modeling.html#default-settings explains how it works
- Parameters:
node (xml.etree.ElementTree.Element) –
parent (xml.etree.ElementTree.Element) –
- _parse_material(material)[source]#
Parse MJCF materials in asset to sapien render materials
- Parameters:
material (xml.etree.ElementTree.Element) –
- _parse_mesh(mesh)[source]#
Parse MJCF mesh data in asset
- Parameters:
mesh (xml.etree.ElementTree.Element) –
- _parse_mjcf(mjcf_string)[source]#
Helper function for self.parse
- Parameters:
mjcf_string (str) –
- Return type:
Tuple[list[sapien.wrapper.articulation_builder.ArticulationBuilder], list[sapien.ActorBuilder], None]
- _parse_texture(texture)[source]#
Parse MJCF textures to then be referenced by materials: https://mujoco.readthedocs.io/en/stable/XMLreference.html#asset-texture
NOTE: - Procedural texture generation is currently not supported. - Different texture types are not really supported
- Parameters:
texture (xml.etree.ElementTree.Element) –
- load(mjcf_file, package_dir=None)[source]#
Parses a given mjcf .xml file and builds all articulations and actors
- Parameters:
mjcf_file (str) –
- parse(mjcf_file, package_dir=None)[source]#
Parses a given MJCF file into articulation builders and actor builders and sensor configs
- Parameters:
mjcf_file (str) –
- _textures: dict[str, MJCFTexture][source]#
- fix_root_link = True[source]#
whether to fix the root link. Note regardless of given XML, the root link is a dummy link this loader creates which makes a number of operations down the line easier. In general this should be False if there is a freejoint for the root body of articulations in the XML and should be true if there are no free joints. At the moment when modelling a robot from Mujoco this must be handled on a case by case basis
- mani_skill.utils.building._mjcf_loader._merge_attrib(default_attrib, incoming_attribs)[source]#
- Parameters:
default_attrib (dict) –
incoming_attribs (Union[list[dict], dict]) –