fix: NaN chain break — rewards, std, obs, physics all protected
This commit is contained in:
@@ -419,7 +419,7 @@ class DreamWaQTask(Go1WalkTask):
|
||||
cy = half_y - self._border - row * self._cell_size - self._cell_size / 2
|
||||
all_origins[row, col] = [cx, cy]
|
||||
self._terrain_origins = all_origins
|
||||
self._max_init_level = 5 # 上游原值,随机 0-5 起步
|
||||
self._max_init_level = 3 # 先 0-3,适应后再提到 5
|
||||
|
||||
if num_reset > 0 and self._init_done and state is not None and hasattr(state, 'info'):
|
||||
old_info = state.info
|
||||
@@ -610,7 +610,8 @@ class DreamWaQTask(Go1WalkTask):
|
||||
}
|
||||
# state.reward 直接用带 dt 的值(不调 super,super 不带 dt)
|
||||
state = state.replace(reward=np.zeros(self._num_envs, dtype=np.float32))
|
||||
for v in scaled_terms.values():
|
||||
for k, v in scaled_terms.items():
|
||||
v = np.nan_to_num(v, nan=0.0, posinf=0.0, neginf=0.0)
|
||||
state.reward += v
|
||||
if self._cfg.reward_config.only_positive_rewards:
|
||||
state.reward = np.maximum(state.reward, 0.0)
|
||||
@@ -650,9 +651,11 @@ class DreamWaQTask(Go1WalkTask):
|
||||
return np.square(base_z - ground_level - target)
|
||||
|
||||
def _reward_joint_power(self, data):
|
||||
torque = np.clip(data.actuator_ctrls, -100, 100)
|
||||
vel = np.clip(self.get_dof_vel(data), -100, 100)
|
||||
return np.sum(np.abs(torque * vel), axis=1)
|
||||
torque = np.nan_to_num(data.actuator_ctrls, nan=0.0)
|
||||
vel = np.nan_to_num(self.get_dof_vel(data), nan=0.0)
|
||||
torque = np.clip(torque, -100, 100)
|
||||
vel = np.clip(vel, -100, 100)
|
||||
return np.clip(np.sum(np.abs(torque * vel), axis=1), 0, 1e6)
|
||||
|
||||
def _reward_smoothness(self, info):
|
||||
scale = self.cfg.control_config.action_scale
|
||||
@@ -666,7 +669,9 @@ class DreamWaQTask(Go1WalkTask):
|
||||
return np.sum(diff, axis=1)
|
||||
|
||||
def _reward_power_distribution(self, data):
|
||||
torque = np.clip(data.actuator_ctrls, -100, 100)
|
||||
vel = np.clip(self.get_dof_vel(data), -100, 100)
|
||||
torque = np.nan_to_num(data.actuator_ctrls, nan=0.0)
|
||||
vel = np.nan_to_num(self.get_dof_vel(data), nan=0.0)
|
||||
torque = np.clip(torque, -100, 100)
|
||||
vel = np.clip(vel, -100, 100)
|
||||
power = torque * vel
|
||||
return np.var(np.abs(power), axis=1)
|
||||
return np.nan_to_num(np.var(np.abs(power), axis=1), nan=0.0)
|
||||
|
||||
Reference in New Issue
Block a user