rofunc.learning.utils.env_wrappers#
1. Module Contents#
1.1. Classes#
1.2. Functions#
Wrap an environment to use a common interface :param env: The environment to be wrapped :param wrapper: The type of wrapper to use (default: “auto”). |
1.3. API#
- class rofunc.learning.utils.env_wrappers.Wrapper(env: Any, device=None)[source]#
Bases:
objectInitialization
Base wrapper class for RL environments
- Parameters:
env (Any supported RL environment) – The environment to wrap
- abstract reset() Tuple[torch.Tensor, Any][source]#
Reset the environment
- Raises:
NotImplementedError – Not implemented
- Returns:
Observation, info
- Return type:
torch.Tensor and any other info
- abstract step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Raises:
NotImplementedError – Not implemented
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- abstract render(*args, **kwargs) None[source]#
Render the environment
- Raises:
NotImplementedError – Not implemented
- property num_envs: int#
Number of environments
If the wrapped environment does not have the
num_envsproperty, it will be set to 1
- property state_space: gym.Space#
State space
If the wrapped environment does not have the
state_spaceproperty, the value of theobservation_spaceproperty will be used
- property observation_space: gym.Space#
Observation space
- property action_space: gym.Space#
Action space
- class rofunc.learning.utils.env_wrappers.IsaacGymPreview2Wrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Isaac Gym environment (preview 2) wrapper
- Parameters:
env (Any supported Isaac Gym environment (preview 2) environment) – The environment to wrap
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.IsaacGymPreview3Wrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Isaac Gym environment (preview 3) wrapper
- Parameters:
env (Any supported Isaac Gym environment (preview 3) environment) – The environment to wrap
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.OmniverseIsaacGymWrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Omniverse Isaac Gym environment wrapper
- Parameters:
env (Any supported Omniverse Isaac Gym environment) – The environment to wrap
- run(trainer: Optional[omni.isaac.gym.vec_env.vec_env_mt.TrainerMT] = None) None[source]#
Run the simulation in the main thread
This method is valid only for the Omniverse Isaac Gym multi-threaded environments
- Parameters:
trainer (omni.isaac.gym.vec_env.vec_env_mt.TrainerMT, optional) – Trainer which should implement a
runmethod that initiates the RL loop on a new thread
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.IsaacOrbitWrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Isaac Orbit environment wrapper
- Parameters:
env (Any supported Isaac Orbit environment) – The environment to wrap
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.GymWrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
OpenAI Gym environment wrapper
- Parameters:
env (Any supported OpenAI Gym environment) – The environment to wrap
- property state_space: gym.Space#
State space
An alias for the
observation_spaceproperty
- property observation_space: gym.Space#
Observation space
- property action_space: gym.Space#
Action space
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.GymnasiumWrapper(env: Any, seed: int = None)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Gymnasium environment wrapper
- Parameters:
env (Any supported Gymnasium environment) – The environment to wrap
- property state_space: gymnasium.Space#
State space
An alias for the
observation_spaceproperty
- property observation_space: gymnasium.Space#
Observation space
- property action_space: gymnasium.Space#
Action space
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- class rofunc.learning.utils.env_wrappers.DeepMindWrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
DeepMind environment wrapper
- Parameters:
env (Any supported DeepMind environment) – The environment to wrap
- property state_space: gym.Space#
State space
An alias for the
observation_spaceproperty
- property observation_space: gym.Space#
Observation space
- property action_space: gym.Space#
Action space
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- reset() Tuple[torch.Tensor, Any][source]#
Reset the environment
- Returns:
The state of the environment
- Return type:
torch.Tensor
- class rofunc.learning.utils.env_wrappers.RobosuiteWrapper(env: Any)[source]#
Bases:
rofunc.learning.utils.env_wrappers.WrapperInitialization
Robosuite environment wrapper
- Parameters:
env (Any supported robosuite environment) – The environment to wrap
- property state_space: gym.Space#
State space
An alias for the
observation_spaceproperty
- property observation_space: gym.Space#
Observation space
- property action_space: gym.Space#
Action space
- step(actions: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Any][source]#
Perform a step in the environment
- Parameters:
actions (torch.Tensor) – The actions to perform
- Returns:
Observation, reward, terminated, truncated, info
- Return type:
tuple of torch.Tensor and any other info
- rofunc.learning.utils.env_wrappers.wrap_env(env: Any, wrapper: str = 'auto', verbose: bool = True, logger=None, seed=None) rofunc.learning.utils.env_wrappers.Wrapper[source]#
Wrap an environment to use a common interface :param env: The environment to be wrapped :param wrapper: The type of wrapper to use (default: “auto”).
If
"auto", the wrapper will be automatically selected based on the environment class. The supported wrappers are described in the following table:Environment
Wrapper tag
OpenAI Gym
"gym"Gymnasium
"gymnasium"DeepMind
"dm"Robosuite
"robosuite"Isaac Gym preview 2
"isaacgym-preview2"Isaac Gym preview 3
"isaacgym-preview3"Isaac Gym preview 4
"isaacgym-preview4"Omniverse Isaac Gym
"omniverse-isaacgym"Isaac Sim (orbit)
"isaac-orbit"- Parameters:
verbose – Whether to print the wrapper type (default: True)
logger – rofunc logger (default: None)
seed – random seed for env (default: None)