diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 41c7708975d..f026916ec98 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -93,6 +93,7 @@ Guidelines for modifications: * Ryley McCarroll * Shafeef Omar * Shundo Kishi +* Stefan Van de Mosselaer * Stephan Pleines * Tyler Lum * Victor Khaustov diff --git a/source/isaaclab/config/extension.toml b/source/isaaclab/config/extension.toml index 13442f8b227..c4980d59b93 100644 --- a/source/isaaclab/config/extension.toml +++ b/source/isaaclab/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.36.6" +version = "0.36.7" # Description title = "Isaac Lab framework for Robot Learning" diff --git a/source/isaaclab/docs/CHANGELOG.rst b/source/isaaclab/docs/CHANGELOG.rst index b0558396b97..196446c43d7 100644 --- a/source/isaaclab/docs/CHANGELOG.rst +++ b/source/isaaclab/docs/CHANGELOG.rst @@ -1,6 +1,21 @@ Changelog --------- +0.36.7 (2025-04-17) +~~~~~~~~~~~~~~~~~~~ + +Added +^^^^^ + +* Added initialization of ``episode_length_buf`` in :meth:`load_managers()` of :class:`~isaaclab.envs.ManagerBasedRLEnv` + to make it available for use in mdp functions. Note: existing initialization in :meth:`__init__` left in place in case + it is needed for other use cases. +* Added :attr:`~isaaclab.envs.ManagerBasedRLEnv.curr_episode_length` to :class:`~isaaclab.envs.ManagerBasedRLEnv` which + returns reshaped ``episode_length_buf`` so it is visible as an attribute in the documentation. +* Added time observation functions to ~isaaclab.envs.mdp.observations module, + :func:`~isaaclab.envs.mdp.observations.current_time_s` and :func:`~isaaclab.envs.mdp.observations.remaining_time_s`. + + 0.36.6 (2025-04-09) ~~~~~~~~~~~~~~~~~~~ diff --git a/source/isaaclab/isaaclab/envs/manager_based_rl_env.py b/source/isaaclab/isaaclab/envs/manager_based_rl_env.py index 43713ef5ad0..d67751e3e15 100644 --- a/source/isaaclab/isaaclab/envs/manager_based_rl_env.py +++ b/source/isaaclab/isaaclab/envs/manager_based_rl_env.py @@ -75,14 +75,16 @@ def __init__(self, cfg: ManagerBasedRLEnvCfg, render_mode: str | None = None, ** # -- counter for curriculum self.common_step_counter = 0 + # initialize the episode length buffer BEFORE loading the managers so it is available for use by mdp functions. + self.cfg = cfg + self.episode_length_buf = torch.zeros(self.cfg.scene.num_envs, device=self.cfg.sim.device, dtype=torch.long) + # initialize the base class to setup the scene. super().__init__(cfg=cfg) # store the render mode self.render_mode = render_mode # initialize data and constants - # -- init buffers - self.episode_length_buf = torch.zeros(self.num_envs, device=self.device, dtype=torch.long) # -- set the framerate of the gym video recorder wrapper so that the playback speed of the produced video matches the simulation self.metadata["render_fps"] = 1 / self.step_dt @@ -107,6 +109,7 @@ def max_episode_length(self) -> int: """ def load_managers(self): + # note: this order is important since observation manager needs to know the command and action managers # and the reward manager needs to know the termination manager # -- command manager diff --git a/source/isaaclab/isaaclab/envs/mdp/observations.py b/source/isaaclab/isaaclab/envs/mdp/observations.py index 12e93b69d28..6df701bccc6 100644 --- a/source/isaaclab/isaaclab/envs/mdp/observations.py +++ b/source/isaaclab/isaaclab/envs/mdp/observations.py @@ -529,3 +529,18 @@ def last_action(env: ManagerBasedEnv, action_name: str | None = None) -> torch.T def generated_commands(env: ManagerBasedRLEnv, command_name: str) -> torch.Tensor: """The generated command from command term in the command manager with the given name.""" return env.command_manager.get_command(command_name) + + +""" +Time. +""" + + +def current_time_s(env: ManagerBasedRLEnv) -> torch.Tensor: + """The current time in the episode (in seconds).""" + return env.episode_length_buf.unsqueeze(1) * env.step_dt + + +def remaining_time_s(env: ManagerBasedRLEnv) -> torch.Tensor: + """The maximum time remaining in the episode (in seconds).""" + return env.max_episode_length_s - env.episode_length_buf.unsqueeze(1) * env.step_dt