unilab.base.backend.mujoco.xml

Functions

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

在 MuJoCo XML 的 sensor 节点下添加传感器的通用函数。

create_discardvisual_xml(model_file)

get_named_body_ids(model_file, names)

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

inject_mujoco_tracking_sensors(model_file[, ...])

为 MuJoCo 后端注入 tracking sensors。

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)

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

model_file (str)

Return type:

str

unilab.base.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]

unilab.base.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

unilab.base.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

unilab.base.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]

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

为 MuJoCo 后端注入 tracking sensors。

注入所有 body 的世界系 (_w) sensors;若指定 baselink_name, 同时注入相对 baselink 坐标系的 (_b) sensors。

Return type:

tuple[str, list, list]

Returns:

(tmp_xml_path, tracked_body_ids, valid_bnames)

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

在 MuJoCo XML 的 sensor 节点下添加传感器的通用函数。

参数: - root: XML 的根节点 - sensor_type: 传感器标签名 (如 ‘gyro’, ‘contact’, ‘framepos’) - name: 传感器的 name 属性 - **kwargs: 其他任意属性 (如 site=’imu’, geom1=’floor’ 等)