unisim.backend.genesis.materialization¶
Cold-path scene materialization for the independent genesis backend.
Genesis 1.3.3 drops three MJCF features UniLab relies on (measured in
scripts/tools/genesis_feasibility/REPORT.md #1372 §3): <keyframe>,
the global <option> block, and the whole <sensor> block. This module
compensates on the cold path exactly as the report prescribes: keyframe and
sensor metadata are scanned once with the mujoco package (the isaacgym
parent-process metadata-scan pattern) and cached — hot paths never parse XML;
global options arrive as explicit owner fields; and gs.init host-side
effects (torch default device/dtype and RNG) are contained by
preserve_torch_globals() plus the one-session-per-process guard.
Functions
|
Construct the unbuilt Genesis scene with explicit global options. |
|
Tear down the process-wide session; re-initialization stays forbidden. |
|
Initialize the process-wide Genesis session exactly once. |
|
Snapshot torch global defaults and restore them after |
|
Resolve the scene and scan MJCF metadata with the |
Classes
MJCF metadata scanned once on the cold path (never on hot paths). |
|
One MJCF sensor mapped onto a Genesis-readable equivalent. |
- class unisim.backend.genesis.materialization.GenesisSensorPlan[source]¶
Bases:
objectOne MJCF sensor mapped onto a Genesis-readable equivalent.
body_nameis the owning link for site sensors and the robot-side geom body for contact sensors.site_pos/site_quat(wxyz) are the local site frame in the body frame; both areNonefor contact sensors.- Parameters:
- class unisim.backend.genesis.materialization.GenesisModelMetadata[source]¶
Bases:
objectMJCF metadata scanned once on the cold path (never on hot paths).
- Parameters:
source_model_file (
str)nq (
int)nv (
int)nbody (
int)root_qpos_dim (
int)root_qvel_dim (
int)actuator_ctrl_range (
ndarray)actuator_kp (
ndarray)actuator_kv (
ndarray)default_qpos (
ndarray)dof_armature (
ndarray)gravity (
ndarray)body_mass (
ndarray)body_ipos (
ndarray)sensor_plans (
tuple[GenesisSensorPlan,...])
-
sensor_plans:
tuple[GenesisSensorPlan,...]¶
- __init__(source_model_file, cleanup_handle, nq, nv, nbody, root_qpos_dim, root_qvel_dim, joint_names, joint_qpos_adrs, joint_dof_adrs, body_names, actuator_names, actuator_joint_names, actuator_ctrl_range, actuator_kp, actuator_kv, keyframe_qpos, default_qpos, joint_range, dof_armature, gravity, body_mass, body_ipos, sensor_plans)¶
- Parameters:
source_model_file (
str)nq (
int)nv (
int)nbody (
int)root_qpos_dim (
int)root_qvel_dim (
int)actuator_ctrl_range (
ndarray)actuator_kp (
ndarray)actuator_kv (
ndarray)default_qpos (
ndarray)dof_armature (
ndarray)gravity (
ndarray)body_mass (
ndarray)body_ipos (
ndarray)sensor_plans (
tuple[GenesisSensorPlan,...])
- unisim.backend.genesis.materialization.preserve_torch_globals(torch)[source]¶
Snapshot torch global defaults and restore them after
gs.init.gs.initmutates the host process: it forcestorch.set_default_device("cuda:0")on the GPU lane, and passingseed=would reseed the global RNG (REPORT #1372 §3.5 [10]). The adapter never passes a seed and restores default device/dtype plus the torch RNG state so the training process observes no pollution (REPORT #1372 §5.8).
- unisim.backend.genesis.materialization.init_genesis_session(deps, *, device_id=None, logging_level='warning')[source]¶
Initialize the process-wide Genesis session exactly once.
Repeated
init -> destroycycles are functional but leak 200-450 MB of host RSS per cycle (REPORT #1372 §3.5 [9a]), so a long-lived training process gets exactly one session. Multiple GenesisBackend instances share the live session (multi-scene coexistence is measured OK, REPORT [9b]); afterdestroy_genesis_session()any further construction fails closed with a clear error.
- unisim.backend.genesis.materialization.destroy_genesis_session(deps)[source]¶
Tear down the process-wide session; re-initialization stays forbidden.
- unisim.backend.genesis.materialization.build_genesis_scene(deps, *, sim_dt, gravity, integrator, constraint_solver, friction_cone, solver_iterations)[source]¶
Construct the unbuilt Genesis scene with explicit global options.