Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.48k stars 726 forks source link

Creating a New Environment #599

Closed vinay06vinay closed 1 month ago

vinay06vinay commented 1 month ago

Hello,

I have a query about creating a new custom environment and registering it. The current documentation is not clear

  1. Firstly, the "register( id='your-env-v0', entry_point='highway_env.envs:YourEnv', )" should be inside highway_env/init.py file as other environments

  2. Secondly, I am not able to understand how to make my custom-created environment (created inside envs) in my local workspace be registered with Gymansium and use it. Does only pull requests work to make our custom environments work? Cant we make an environment locally and test ? I tried "import highway_env highway_env.register_highway_envs()"

but I think its not considering my local repo instead use the highway_env library installed

Could you please assist or update documentation on creating an environment locally

franzherm commented 1 month ago

A dirty fix that worked for me was to append the local repo to the python search path within the file _highwayenv/envs/__init__.py like that:

import sys
sys.path.append('path/to/the/folder/containing/your/env')
from your_env_file import *
eleurent commented 1 month ago

Yes, you should do add it to highway_env/init.py and then do

import highway_env
highway_env.register_highway_envs()

And for highway_env to be importable, it needs to be in your path, so if it's not already:

import sys
sys.path.append('path/to/the/folder/containing/highway_env')

I'll update the docs, they are outdated.

EDIT: the docs were actually up to date, so you can just follow that.