Skip to content

Commit

Permalink
Get cost from info dict hopper-v5
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasAlegre committed Oct 27, 2024
1 parent b18a31c commit d7135c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mo_gymnasium/envs/mujoco/hopper_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ def step(self, action):
observation, reward, terminated, truncated, info = super().step(action)
x_velocity = info["x_velocity"]
height = 10 * info["z_distance_from_origin"]
energy_cost = np.sum(np.square(action))
if self.cost_objetive:
vec_reward = np.array([x_velocity, height, -energy_cost], dtype=np.float32)
neg_energy_cost = info["reward_ctrl"]
if self._cost_objetive:
neg_energy_cost /= self._ctrl_cost_weight # Revert the scale applied in the original environment
vec_reward = np.array([x_velocity, height, neg_energy_cost], dtype=np.float32)
else:
vec_reward = np.array([x_velocity, height], dtype=np.float32)
vec_reward -= self._ctrl_cost_weight * energy_cost
vec_reward += neg_energy_cost

vec_reward += info["reward_survive"]

Expand Down

0 comments on commit d7135c6

Please sign in to comment.