Skip to content

Feat: 接入唯一 NumPy ManagerBasedRlEnv lifecycle #1049

Description

@TATP-233

普通说明

只做一件事:把已迁移的 managers 接入 UniLab 唯一的 NpEnv step/reset/autoreset 生命周期,交付 canonical ManagerBasedRlEnv / ManagerBasedRlEnvCfg。它继续返回 NpEnvState,使用 NumPy、现有 SimBackend、base-owned entity facade 和显式 observation group 映射。

不迁移任何 production task,不新建第二套 step loop、runner、IPC、scene 或 backend abstraction,不接入 legacy DomainRandomizationManager。预计 6–12 个文件、≤1,500 行 UniLab-specific 手写改动、1 个 PR。永久维护成本是一层薄的 lifecycle adapter、一个预分配 control buffer、manager 顺序/映射 tests;不增加长期兼容分支。

最小交付结果

  • 新增 ManagerBasedRlEnvCfg(EnvCfg):manager dictionaries、env-owned seed/RNG、reward dt scaling、finite-horizon、autoreset,以及明确的 policy/critic observation group mapping。
  • 新增 ManagerBasedRlEnv(NpEnv)ManagerBasedRLEnv / ManagerBasedRLEnvCfg 若导出,只能是同一对象 alias。
  • 初始化顺序固定为 event → command → action → observation → termination → reward → curriculum → metrics → recorder。
  • step 复用 NpEnv.step():action process/apply、termination/reward/metrics、step/interval event、command、observation 和 reset hooks 保持 pinned mjlab 时序,并保留 NpEnvState、final observation、局部 reset 与 IPC 数据面。
  • entity facade 增加写入 env-owned actuator control buffer 的最小 EntityData.write_ctrl;不新增 backend 方法。
  • timeout 由 TerminationManager 唯一映射为 terminated/truncated;不再叠加 NpEnv._compute_truncated()

In scope

  • manager lifecycle adapter、公共 exports、配置验证和 focused fake-backend fixture。
  • physics_dt / step_dt / episode counters / manager buffers 等 community term context。
  • env-owned np.random.Generator;reset seed 原地更新同一 generator,使已构造 term/noise model 保持引用。
  • 明确把配置的 policy group 映射为 NpEnvState.obs["obs"],可选 critic group映射为 "critic";非 concatenated、非二维或重复映射直接报错。
  • manager logging 写入 state.info["log"];recorder pre-reset/post-reset/post-step 顺序有测试。

Non-goals

  • 不迁移 Go2 或其他 task,不增加 built-in observation/reward/event/action catalog。
  • 不修改 runner、learner、scripts、IPC、Hydra compose 或 registry。
  • 不新增 SimBackend public method,不访问 backend 私有状态。
  • 不支持需要 post-substep hook 的 MetricsTermCfg(per_substep=True) + sim_substeps > 1;构造期直接 raise。
  • 不为 mjwarp 的 host pre-step callback 缺口降级;需要多 substep action apply 时构造期直接 raise。
  • 不复用 legacy DR warning/filter/fallback。

Owner 与预算

Env lifecycle / public contract child。≤15 个非删除文件、≤1,500 行 UniLab-specific 手写改动、1 PR;base 为 dev/issue-1042-manager-based-api

Acceptance criteria

  • NpEnv.step() 是唯一 physics/autoreset owner;没有复制的 backend loop 或第二种 state return。
  • manager 初始化、每步计算、局部 reset、command dt=0、observation history 和 recorder hook 顺序由 focused tests 锁定。
  • reset() 返回 (obs_dict, info_dict)obs_groups_spec、final observation、terminated/truncated 与现有 adapter contract 保持一致。
  • action 每个 physics substep应用;可预知的 callback/metrics capability 缺口在 construction-time error,包含 manager/capability/backend。
  • action/observation/reward/done/env IDs/control 全为 NumPy;manager env 对 IPC/runner/scripts 零依赖。
  • 无 legacy DR fallback;focused tests 与 make test-all 通过。

Stop conditions

需要第二套 NpEnvState/step loop、runner/IPC 变化、新 backend public method、backend 私有访问,或为了 substep metrics 引入 post-substep hook时停止并拆独立 owner child。

Umbrella: #1042
Depends on: #1047

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions