Skip to content

wrap_env for custom tensor-based environment #97

Answered by Toni-SM
khanhphan1311 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @khanhphan1311

It is not necessary to wrap an environment as long as it returns the variables and types required by the skrl trainers (as shown in the figure in the Wrapping page in skrl's docs).

For example (for PyTorch): if your environment use gym/gymnasium and the class properties the returns (for .step() and .reset()) are as follows, you can use the environment directly without wrap it.

import gymnasium as gym

class CustomEnv(gym.Env):
    def __init__(self):
        self.observation_space = ...  # gym space
        self.action_space = ...  # gym space
        self.num_envs = ...  # int
        self.device = ...  # torch.device or str
 
    def step(self, action):
        ...
   …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@khanhphan1311
Comment options

@Toni-SM
Comment options

Answer selected by khanhphan1311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants