torchrl.envs.HabitatEnv(*args, **kwargs)[source]

A wrapper for habitat envs.

This class currently serves as placeholder and compatibility security. It behaves exactly like the GymEnv wrapper.





  • env_name (str) – The environment to execute.

  • categorical_action_encoding (bool, optional) – if True, categorical specs will be converted to the TorchRL equivalent (, otherwise a one-hot encoding will be used ( Defaults to False.

Keyword Arguments:
  • from_pixels (bool, optional) – if True, an attempt to return the pixel observations from the env will be performed. By default, these observations will be written under the "pixels" entry. The method being used varies depending on the gym version and may involve a wrappers.pixel_observation.PixelObservationWrapper. Defaults to False.

  • pixels_only (bool, optional) – if True, only the pixel observations will be returned (by default under the "pixels" entry in the output tensordict). If False, observations (eg, states) and pixels will be returned whenever from_pixels=True. Defaults to True.

  • frame_skip (int, optional) – if provided, indicates for how many steps the same action is to be repeated. The observation returned will be the last observation of the sequence, whereas the reward will be the sum of rewards across steps.

  • device (torch.device, optional) – if provided, the device on which the simulation will occur. Defaults to torch.device("cuda:0").

  • batch_size (torch.Size, optional) – the batch size of the environment. Should match the leading dimensions of all observations, done states, rewards, actions and infos. Defaults to torch.Size([]).

  • allow_done_after_reset (bool, optional) – if True, it is tolerated for envs to be done just after reset() is called. Defaults to False.


available_envs (List[str]) – a list of environments to build.


>>> from torchrl.envs import HabitatEnv
>>> env = HabitatEnv("HabitatRenderPick-v0", from_pixels=True)
>>> env.rollout(3)


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources