Skip to content

How to apply omisafe framework to a customized environment? #255

Answered by Gaiejj
Hu-Hanyang asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your support to OmniSafe! We provide interfaces for customizing environments in the omnisafe/envs directory. You can refer to the examples provided in omnisafe/envs/safety_gymnasium_env to customize the environment interface. Key steps include:

  • New a file based on your custom environment, e.g. omnisafe/envs/custom_env.py
  • Define the class based on your custom environment, e.g. CustomEnv
  • Add comments env_register above the class name to register the environment.
@env_register
class CustomEnv(CMDP):
  • List your tasks in _support_envs.
_support_envs: ClassVar[list[str]] = [
      'Custom0-v0',
      'Custom1-v0',
      'Custom2-v0',
    ]
  • Redefine self._env in the __init__ fu…

Replies: 1 comment 2 replies

Comment options

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

@Gaiejj
Comment options

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