rofunc.learning.utils.env_wrappers#

1.  Module Contents#

1.1.  Classes#

Wrapper

IsaacGymPreview2Wrapper

IsaacGymPreview3Wrapper

OmniverseIsaacGymWrapper

IsaacOrbitWrapper

GymWrapper

GymnasiumWrapper

DeepMindWrapper

RobosuiteWrapper

1.2.  Functions#

wrap_env

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: object

Initialization

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

abstract close() None[source]#

Close the environment

Raises:

NotImplementedError – Not implemented

property num_envs: int#

Number of environments

If the wrapped environment does not have the num_envs property, it will be set to 1

property state_space: gym.Space#

State space

If the wrapped environment does not have the state_space property, the value of the observation_space property 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.Wrapper

Initialization

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

reset() Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.IsaacGymPreview3Wrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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

reset() Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.OmniverseIsaacGymWrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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 run method 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

reset() Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.IsaacOrbitWrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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

reset() Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.GymWrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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_space property

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(seed=None) Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.GymnasiumWrapper(env: Any, seed: int = None)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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_space property

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

reset() Tuple[torch.Tensor, Any][source]#

Reset the environment

Returns:

Observation, info

Return type:

torch.Tensor and any other info

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.DeepMindWrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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_space property

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

render(*args, **kwargs) None[source]#

Render the environment

OpenCV is used to render the environment. Install OpenCV with pip install opencv-python

close() None[source]#

Close the environment

class rofunc.learning.utils.env_wrappers.RobosuiteWrapper(env: Any)[source]#

Bases: rofunc.learning.utils.env_wrappers.Wrapper

Initialization

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_space property

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

render(*args, **kwargs) None[source]#

Render the environment

close() None[source]#

Close the environment

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)