duckietown / gym-duckietown

Self-driving car simulator for the Duckietown universe
http://duckietown.org
Other
45 stars 16 forks source link

Error when creating DuckietownEnv with randomize_maps_on_reset parameter set to True. #211

Open AlexKaravaev opened 4 years ago

AlexKaravaev commented 4 years ago

When I create environment via these lines

import gym
import gym_duckietown

def launch_env(id=None):
    env = None
    if id is None:
        # Launch the environment
        from gym_duckietown.simulator import Simulator
        from gym_duckietown.envs.duckietown_env import DuckietownEnv
        env = DuckietownEnv(
            seed=123, # random seed
            map_name="loop_empty",
            max_steps=5001, # we don't want the gym to reset itself
            domain_rand=True,
            camera_width=640,
            camera_height=480,
            accept_start_angle_deg=4, # start close to straight
            full_transparency=True,
            distortion=True,
            randomize_maps_on_reset=True
        )
    else:
        env = gym.make(id)

    return env

This error shows up

self.map_names = os.listdir('maps')
FileNotFoundError: [Errno 2] No such file or directory: 'maps'

I have managed to fix it by chaning line 305 in simulator.py to

self.map_names = os.listdir(os.path.dirname(__file__)+'/maps')