fix: boundary termination, physics crash handler, action_scale 0.25, play script update

This commit is contained in:
8x54zj-m
2026-06-30 19:03:57 +08:00
parent 7affccc695
commit cb62f35ef6
3 changed files with 115 additions and 74 deletions

View File

@@ -109,7 +109,7 @@ class DreamWaQCfg(Go1WalkNpEnvCfg):
self.commands = DreamWaQCfg.Commands()
self.control_config.stiffness = 28.0
self.control_config.damping = 0.7
self.control_config.action_scale = 0.25 # 上游原值(基类默认 0.05
self.control_config.action_scale = 0.25 # 上游原值
self.noise_config.scale_joint_angle = 0.01 # 上游原值(基类默认 0.03
self._apply_dreamwaq()
@@ -530,6 +530,20 @@ class DreamWaQTask(Go1WalkTask):
return obs, info
def update_terminated(self, state):
"""基类接触终止 + hfield 边界终止(防止走出地形导致 NaN"""
state = super().update_terminated(state)
pose = self._body.get_pose(state.data)
base_xy = pose[:, :2]
hf = self._model.get_hfield(0)
b = hf.bound
out_of_bounds = (
(base_xy[:, 0] < b[0]) | (base_xy[:, 0] > b[3]) |
(base_xy[:, 1] < b[1]) | (base_xy[:, 1] > b[4])
)
state.terminated = state.terminated | out_of_bounds
return state
# ── 奖励与上游对齐update_reward 中 × dt──
def _get_reward(self, data: mtx.SceneData, info: dict) -> dict[str, np.ndarray]:

View File

@@ -183,8 +183,19 @@ class NpEnv(ABEnv):
def physics_step(self):
# motrixsim.SceneModel.step only supports single step, so we loop
for _ in range(self._cfg.sim_substeps):
self._model.step(self._state.data)
try:
for _ in range(self._cfg.sim_substeps):
self._model.step(self._state.data)
except Exception as e:
# Rust panic / MotrixSim 物理崩溃 → 标记所有 env 为终止
n = self._state.data.shape[0]
self._state.terminated[:] = True
self._state.reward[:] = 0.0
if not hasattr(self, '_physics_crash_count'):
self._physics_crash_count = 0
self._physics_crash_count += 1
if self._physics_crash_count <= 3:
print(f"[WARN] physics crash #{self._physics_crash_count}: {e} — resetting {n} envs")
def _prev_physics_step(self):
state = self._state