Skip to content

Commit

Permalink
Merge pull request #48 from Maximellerbach/level-name-to-str
Browse files Browse the repository at this point in the history
switched level indexes to str, it will be easier to add new tracks to the gym-donkeycar code
  • Loading branch information
Maximellerbach authored Sep 27, 2020
2 parents 1687f0d + fbc3451 commit 2633a7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions gym_donkeycar/envs/donkey_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 6 additions & 3 deletions gym_donkeycar/envs/donkey_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2633a7a

Please sign in to comment.