diff --git a/gym_donkeycar/envs/donkey_env.py b/gym_donkeycar/envs/donkey_env.py index 64055d9bd..bf106ce34 100755 --- a/gym_donkeycar/envs/donkey_env.py +++ b/gym_donkeycar/envs/donkey_env.py @@ -137,34 +137,34 @@ def is_game_over(self): class GeneratedRoadsEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(GeneratedRoadsEnv, self).__init__(level=0, *args, **kwargs) + super(GeneratedRoadsEnv, self).__init__(level='generated_road', *args, **kwargs) class WarehouseEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(WarehouseEnv, self).__init__(level=1, *args, **kwargs) + super(WarehouseEnv, self).__init__(level='warehouse', *args, **kwargs) class AvcSparkfunEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(AvcSparkfunEnv, self).__init__(level=2, *args, **kwargs) + super(AvcSparkfunEnv, self).__init__(level='sparkfun_avc', *args, **kwargs) class GeneratedTrackEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(GeneratedTrackEnv, self).__init__(level=3, *args, **kwargs) + super(GeneratedTrackEnv, self).__init__(level='generated_track', *args, **kwargs) class MountainTrackEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(MountainTrackEnv, self).__init__(level=4, *args, **kwargs) + super(MountainTrackEnv, self).__init__(level='mountain_track', *args, **kwargs) class RoboRacingLeagueTrackEnv(DonkeyEnv): def __init__(self, *args, **kwargs): - super(RoboRacingLeagueTrackEnv, self).__init__(level=5, *args, **kwargs) + super(RoboRacingLeagueTrackEnv, self).__init__(level='roboracingleague_1', *args, **kwargs) diff --git a/gym_donkeycar/envs/donkey_sim.py b/gym_donkeycar/envs/donkey_sim.py index cc782ccd5..b6823efa2 100755 --- a/gym_donkeycar/envs/donkey_sim.py +++ b/gym_donkeycar/envs/donkey_sim.py @@ -81,7 +81,7 @@ class DonkeyUnitySimHandler(IMesgHandler): def __init__(self, conf): self.conf = conf - self.iSceneToLoad = conf["level"] + self.SceneToLoad = conf["level"] self.loaded = False self.max_cte = conf["max_cte"] self.timer = FPSTimer() @@ -320,8 +320,11 @@ def on_recv_scene_names(self, data): if data: names = data['scene_names'] logger.debug(f"SceneNames: {names}") - print("loading scene", self.iSceneToLoad, names[self.iSceneToLoad]) - self.send_load_scene(names[self.iSceneToLoad]) + print("loading scene", self.SceneToLoad) + if self.SceneToLoad in names: + self.send_load_scene(self.SceneToLoad) + else: + raise ValueError("Scene name not in scene list") def send_control(self, steer, throttle): if not self.loaded: