unisim.backend.mujoco.xml

Functions

add_sensor(root, sensor_type, name, **kwargs)

Add a sensor child under the MuJoCo XML <sensor> node.

create_discardvisual_xml(model_file)

get_named_bodies(model_file)

List MuJoCo-style body ids and names declared in a (possibly included) XML.

get_named_body_ids(model_file, names)

Resolve MuJoCo-style body ids from XML without importing mujoco.

inject_mujoco_tracking_sensors(model_file[, ...])

Inject tracking sensors for the MuJoCo backend.

materialize_mujoco_hfield_attached_scene(*, ...)

Build a MuJoCo model with generated hfield terrain and attached robot spec.

materialize_scene_fragments(...)

Create a temporary scene XML with task/scene fragments merged.

materialize_scene_visual_override(...[, ...])

Create a temporary scene XML with visual-only overrides applied.

processed_xml(xml_path)

unisim.backend.mujoco.xml.create_discardvisual_xml(model_file)[source]
Parameters:

model_file (str)

Return type:

str

unisim.backend.mujoco.xml.get_named_bodies(model_file)[source]

List MuJoCo-style body ids and names declared in a (possibly included) XML.

Returns (ids, names) in document order, with ids starting at 1 (the MuJoCo implicit world body 0 is not listed).

Parameters:

model_file (str)

Return type:

tuple[list[int], list[str]]

unisim.backend.mujoco.xml.get_named_body_ids(model_file, names)[source]

Resolve MuJoCo-style body ids from XML without importing mujoco.

Parameters:
Return type:

list[int]

unisim.backend.mujoco.xml.materialize_scene_visual_override(source_model_file, *, ground_texture_file=None, ground_texrepeat=None, skybox_rgb1=None, skybox_rgb2=None)[source]

Create a temporary scene XML with visual-only overrides applied.

Parameters:
Return type:

str

unisim.backend.mujoco.xml.materialize_scene_fragments(source_model_file, *, fragment_files)[source]

Create a temporary scene XML with task/scene fragments merged.

Parameters:
Return type:

str

unisim.backend.mujoco.xml.materialize_mujoco_hfield_attached_scene(*, model_file, terrain_cfg, output_dir, fragment_files=(), hfield_name='terrain_hfield', geom_name='floor', return_surface_sampler=False)[source]

Build a MuJoCo model with generated hfield terrain and attached robot spec.

Parameters:
Return type:

tuple[Any, ndarray] | tuple[Any, ndarray, Any]

unisim.backend.mujoco.xml.inject_mujoco_tracking_sensors(model_file, baselink_name=None)[source]

Inject tracking sensors for the MuJoCo backend.

The generated sensors track every body in the world frame (_w). When baselink_name is provided, sensors in the baselink-relative frame (_b) are added as well.

Return type:

tuple[str, list, list]

Returns:

(tmp_xml_path, tracked_body_ids, valid_bnames)

Parameters:
unisim.backend.mujoco.xml.processed_xml(xml_path)[source]
unisim.backend.mujoco.xml.add_sensor(root, sensor_type, name, **kwargs)[source]

Add a sensor child under the MuJoCo XML <sensor> node.

Parameters:
  • root – XML root node.

  • sensor_type – Sensor tag name, such as "gyro", "contact", or "framepos".

  • name – Sensor name attribute.

  • **kwargs – Additional XML attributes such as site="imu" or geom1="floor".