mani_skill.utils.building._mjcf_loader ====================================== .. py:module:: mani_skill.utils.building._mjcf_loader .. autoapi-nested-parse:: Loader code to import MJCF xml files into SAPIEN Code partially adapted from https://github.com/NVIDIA/warp/blob/3ed2ceab824b65486c5204d2a7381d37b79fc314/warp/sim/import_mjcf.py Articulations are known as kinematic trees (defined by tags) in Mujoco. A single .xml file can have multiple articulations Any tag in but not a 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) .. rubric:: 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 ---------- .. autoapisummary:: mani_skill.utils.building._mjcf_loader.DEFAULT_MJCF_OPTIONS mani_skill.utils.building._mjcf_loader.WARNED_ONCE Classes ------- .. autoapisummary:: mani_skill.utils.building._mjcf_loader.MJCFLoader mani_skill.utils.building._mjcf_loader.MJCFTexture Functions --------- .. autoapisummary:: mani_skill.utils.building._mjcf_loader._merge_attrib mani_skill.utils.building._mjcf_loader._parse_float mani_skill.utils.building._mjcf_loader._parse_int mani_skill.utils.building._mjcf_loader._parse_orientation mani_skill.utils.building._mjcf_loader._parse_vec mani_skill.utils.building._mjcf_loader._str_to_float Module Contents --------------- .. py:class:: MJCFLoader(ignore_classes=['motor'], visual_groups=[0, 2]) Class to load MJCF into SAPIEN. .. py:method:: _build_geom(geom, builder, defaults) .. py:method:: _build_link(body, body_attrib, link_builder, defaults) sets inertial, visual/collision shapes .. py:method:: _parse_body(body, parent, incoming_defaults, builder) .. py:method:: _parse_constraint(constraint) .. py:method:: _parse_default(node, parent) Parse a MJCF default attribute. https://mujoco.readthedocs.io/en/stable/modeling.html#default-settings explains how it works .. py:method:: _parse_material(material) Parse MJCF materials in asset to sapien render materials .. py:method:: _parse_mesh(mesh) Parse MJCF mesh data in asset .. py:method:: _parse_mjcf(mjcf_string) Helper function for self.parse .. py:method:: _parse_texture(texture) 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 .. py:method:: _pose_from_origin(origin, scale) :staticmethod: .. py:method:: load(mjcf_file, package_dir=None) Parses a given mjcf .xml file and builds all articulations and actors .. py:method:: parse(mjcf_file, package_dir=None) Parses a given MJCF file into articulation builders and actor builders and sensor configs .. py:method:: set_scene(scene) .. py:attribute:: _assets .. py:attribute:: _defaults :type: dict[str, xml.etree.ElementTree.Element] .. py:attribute:: _group_count :value: 0 .. py:attribute:: _link2builder :type: dict[str, sapien.wrapper.articulation_builder.LinkBuilder] .. py:attribute:: _link2parent_joint :type: dict[str, Any] .. py:attribute:: _materials .. py:attribute:: _meshes :type: dict[str, xml.etree.ElementTree.Element] .. py:property:: _root_default .. py:attribute:: _textures :type: dict[str, MJCFTexture] .. py:attribute:: density :value: 1000 .. py:attribute:: fix_root_link :value: True 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 .. py:attribute:: ignore_classes :value: ['motor'] .. py:attribute:: load_multiple_collisions_from_file :value: False .. py:attribute:: load_nonconvex_collisions :value: False .. py:attribute:: multiple_collisions_decomposition :value: 'none' .. py:attribute:: multiple_collisions_decomposition_params .. py:attribute:: revolute_unwrapped :value: False .. py:attribute:: scale :value: 1.0 .. py:attribute:: scene :type: sapien.Scene :value: None .. py:attribute:: visual_groups :value: [0, 2] .. py:class:: MJCFTexture .. py:attribute:: file :type: str .. py:attribute:: name :type: str .. py:attribute:: rgb1 :type: list .. py:attribute:: rgb2 :type: list .. py:attribute:: type :type: Literal['skybox', 'cube', '2d'] .. py:function:: _merge_attrib(default_attrib, incoming_attribs) .. py:function:: _parse_float(attrib, key, default) .. py:function:: _parse_int(attrib, key, default) .. py:function:: _parse_orientation(attrib, use_degrees, euler_seq) .. py:function:: _parse_vec(attrib, key, default) .. py:function:: _str_to_float(string, delimiter=' ') .. py:data:: DEFAULT_MJCF_OPTIONS .. py:data:: WARNED_ONCE