Skip to content

Commit

Permalink
Merge pull request #35 from yang-zj1026/main
Browse files Browse the repository at this point in the history
Include time_outs in environment info for PPO
  • Loading branch information
zhenjia-xu authored Dec 19, 2024
2 parents 19de196 + ff89add commit 6590acc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/locomotion/go2_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def step(self, actions):
self.reset_buf = self.episode_length_buf > self.max_episode_length
self.reset_buf |= torch.abs(self.base_euler[:, 1]) > self.env_cfg["termination_if_pitch_greater_than"]
self.reset_buf |= torch.abs(self.base_euler[:, 0]) > self.env_cfg["termination_if_roll_greater_than"]

time_out_idx = (self.episode_length_buf > self.max_episode_length).nonzero(as_tuple=False).flatten()
self.extras["time_outs"] = torch.zeros_like(self.reset_buf, device=self.device, dtype=gs.tc_float)
self.extras["time_outs"][time_out_idx] = 1.0

self.reset_idx(self.reset_buf.nonzero(as_tuple=False).flatten())

# compute reward
Expand Down

0 comments on commit 6590acc

Please sign in to comment.