unilab.base.backend.motrix.backend.MotrixBackend¶
- class unilab.base.backend.motrix.backend.MotrixBackend[source]¶
Bases:
SimBackendMotrixSim 后端实现
- Parameters:
Methods
__init__(scene, num_envs, sim_dt[, ...])apply_body_force(body_ids, force)Apply absolute world-frame external forces through Motrix Link API.
apply_body_linear_velocity_delta(body_ids, ...)Apply a world-frame linear-velocity delta to specific bodies.
apply_init_randomization(plan)Apply cold-path model/materialization randomization.
Apply a scheduled interval randomization plan.
Capture one RGB frame from Motrix's system camera.
Release cold-path scene artifacts owned by the backend.
copy_body_state_w(body_ids, out_pos, ...)Copy selected world-frame body state into caller-owned buffers.
create_hfield_scanner(*, hfield_geom_id, ...)Create a reusable height-field scanner on the init/cold path.
获取执行器控制范围
Return per-joint (kp, kd) arrays from the backend model.
获取 base 在世界系下的角速度
获取 base 在世界系下的线速度
获取 base 在世界系下的位置
获取 base 在世界系下的四元数(wxyz)
get_body_ang_vel_b(body_ids)获取指定 body 在 baselink 系下的角速度
get_body_ang_vel_w(body_ids)获取指定 body 在世界系下的角速度
get_body_id(name)Resolve one body/link name through the backend contract.
get_body_ids(names)将 body/link 名称解析为后端整数 ID
Return the backend body inertial-position table.
get_body_lin_vel_b(body_ids)获取指定 body 在 baselink 系下的线速度
get_body_lin_vel_w(body_ids)获取指定 body 在世界系下的线速度
Return the backend body-mass table.
get_body_pos_b(body_ids)获取指定 body 在 baselink 系下的位置
get_body_pos_w(body_ids)获取指定 body 在世界系下的位置
get_body_pose_w(body_ids)获取指定 body 在世界系下的位置和四元数(wxyz)
get_body_pose_w_rows(env_ids, body_ids)Get selected env rows of world-frame body position and quaternion.
get_body_quat_b(body_ids)获取指定 body 在 baselink 系下的四元数(wxyz)
get_body_quat_w(body_ids)获取指定 body 在世界系下的四元数(wxyz)
get_body_state_w(body_ids)Get selected body position, quaternion, linear velocity, and angular velocity.
get_body_subtree_ids(root_body_id)Return body ids in the subtree rooted at
root_body_id.get_body_vel_w(body_ids)获取指定 body 在世界系下的线速度和角速度
Return the backend/model default qpos through a stable contract.
Return the backend dof-armature table.
获取关节位置(不含 base)
获取关节速度(不含 base)
Return supported domain-randomization capabilities for this backend.
Return the owning body id for each geom.
Return per-geom contact type and affinity masks.
Return the backend geom-friction table.
get_geom_id(name)Resolve one geom name through the backend contract.
Return backend geom names in backend id order.
get_geom_size(name)Return one geom size vector through the backend contract.
Return the backend gravity vector.
获取零初始化的 qvel 向量,维度与 set_state 期望一致
get_joint_dof_indices(names)将关节名称列表转换为速度空间(qvel)的 DoF 索引数组。
get_joint_dof_pos_indices(names)将关节名称列表转换为位置空间(qpos)的 DoF 索引数组。
get_joint_dof_vel_indices(names)将关节名称列表转换为速度空间(qvel)的 DoF 索引数组(相对于关节部分起始)。
获取关节位置限制(不含浮动基座)
get_keyframe_qpos(name)获取指定关键帧的完整 qpos(含浮动基座)
get_motion_body_ids(names)Resolve MuJoCo-style body IDs used by motion datasets.
Return a physics snapshot suitable for offline playback/video export.
Return backend-native play/render capabilities.
get_playback_model([env_index])Return the playback model for a specific env when variants exist.
get_sensor_data(name)获取传感器数据
get_sensor_data_batch(names)Fetch multiple sensors and concatenate their flattened values.
get_sensor_data_rows(name, env_ids)Get selected env rows of a sensor array.
get_site_ids(names)将 site 名称列表转换为整数 ID 数组。
get_site_jacobian_w(site_id, dof_indices)批量计算指定 site 相对于指定 DoF 列的世界系 Jacobian。
init_renderer([spacing, offset_mode, ...])Initialize a Motrix renderer, optionally enabling system-camera capture.
Finalize cold-path backend resources before reset/step.
push_robots(force_range)render()Render current state (interactive visualization)
resolve_play_render_plan(*, ...)Resolve high-level playback mode into backend-owned render parameters.
run_playback(*, env, initialize, step, num_steps)Execute backend-owned playback for an env wrapper.
Register an env-owned policy-control to physics-control converter.
set_state(env_indices, qpos, qvel[, ...])设置指定环境的物理状态
step(ctrl[, nsteps])执行物理步进
Attributes
底层物理模型
执行器数量
关节速度自由度数量(不含浮动基座)
环境数量
- __init__(scene, num_envs, sim_dt, base_name='base', np_dtype=<class 'numpy.float32'>, add_body_sensors=False, max_iterations=3, push_body_name=None)[source]¶
- backend_type: str¶
- property model¶
底层物理模型
- property data¶
- get_actuator_ctrl_range()[source]¶
获取执行器控制范围
- Return type:
- Returns:
(num_actuators, 2) 数组,列为 [low, high]
- get_default_qpos()[source]¶
Return the backend/model default qpos through a stable contract.
- Return type:
- get_body_ids(names)[source]¶
将 body/link 名称解析为后端整数 ID
- Parameters:
- Return type:
- Returns:
(len(names),) int32 数组
- Raises:
ValueError – 若名称未找到
- get_dr_capabilities()[source]¶
Return supported domain-randomization capabilities for this backend.
- Return type:
- apply_init_randomization(plan)[source]¶
Apply cold-path model/materialization randomization.
- Parameters:
plan (
InitRandomizationPlan)- Return type:
- apply_interval_randomization(plan)[source]¶
Apply a scheduled interval randomization plan.
- Parameters:
plan (
IntervalRandomizationPlan)- Return type:
- resolve_play_render_plan(*, play_render_mode, play_steps, output_video)[source]¶
Resolve high-level playback mode into backend-owned render parameters.
- run_playback(*, env, initialize, step, num_steps, output_video=None, render_spacing=None, render_offset_mode=None, headless=None, record_video=None, frame_state_getter=None, camera_kwargs=None, extra_data_getter=None)[source]¶
Execute backend-owned playback for an env wrapper.
- get_base_lin_vel()[source]¶
获取 base 在世界系下的线速度
即广义速度 qvel 的前 3 维,表达在世界坐标系中。
- Return type:
- Returns:
(num_envs, 3)
- get_base_ang_vel()[source]¶
获取 base 在世界系下的角速度
即广义速度 qvel 的第 3-5 维,表达在世界坐标系中。 注意与陀螺仪(gyro)读数的区别:陀螺仪返回的是角速度在 body/sensor 局部坐标系下的分量(即 body frame 表达),而本接口返回的是世界系表达。 若需要 body frame 下的角速度,请使用对应的传感器接口gyro。
- Return type:
- Returns:
(num_envs, 3)
- get_body_pose_w_rows(env_ids, body_ids)[source]¶
Get selected env rows of world-frame body position and quaternion.
- get_body_state_w(body_ids)[source]¶
Get selected body position, quaternion, linear velocity, and angular velocity.
- copy_body_state_w(body_ids, out_pos, out_quat, out_lin_vel, out_ang_vel)[source]¶
Copy selected world-frame body state into caller-owned buffers.
- get_sensor_data_batch(names)[source]¶
Fetch multiple sensors and concatenate their flattened values.
- apply_body_force(body_ids, force)[source]¶
Apply absolute world-frame external forces through Motrix Link API.
- create_hfield_scanner(*, hfield_geom_id, offsets, frame_body_id, alignment='yaw', output='height')[source]¶
Create a reusable height-field scanner on the init/cold path.
Backends that support height-field terrain scan must override this method.
- init_renderer(spacing=1.0, *, offset_mode='grid', headless=False, capture=False, width=1280, height=720, camera_kwargs=None)[source]¶
Initialize a Motrix renderer, optionally enabling system-camera capture.
- apply_body_linear_velocity_delta(body_ids, velocity_delta)¶
Apply a world-frame linear-velocity delta to specific bodies.
- get_body_id(name)¶
Resolve one body/link name through the backend contract.
- get_physics_state()¶
Return a physics snapshot suitable for offline playback/video export.
- Return type:
- get_playback_model(env_index=None)¶
Return the playback model for a specific env when variants exist.
- set_pre_step_control(fn)¶
Register an env-owned policy-control to physics-control converter.
The callback receives
(backend, ctrl)so owner code can read the backend’s freshly-updated sensor contract before every physics substep. It must return backend-native actuator control with the same shape. Position-actuator envs leave this unset and keep the direct control path.