Environments

The UrbanDrivingEnvironment Class

class gym_urbandriving.UrbanDrivingEnv(config_data={}, init_state=None, reward_fn=<function default_reward_function>, randomize=False)[source]

This class controls the evolution of a world state. While the PositionState represents the layout of objects in the scene, the UrbanDrivingEnv controls the evolution of the scene, and manages background actors.

Note

This class is used both to represent the true, global state of the world, and as a search agent’s internal view of the world.

Parameters:
  • config_data (Dict) – JSON config file is loaded into a dictonary specifing prameters
  • init_state (PositionState) – The starting state for this environment (Only needed if now JSON config file is used)
  • reward_fn – A function which takes in one parameter, the PositionState,
  • randomize (bool) – Sets whether env._reset() returns the environment to the initial state, or if it returns it to a random state generated by the state’s randomize() function
_render(mode='human', close=False, waypoints=[], traffic_trajectories=[], transparent_surface=None)[source]

If the renderer was specifed at construction, renders the current state of the world

Parameters:
  • mode (str) – For OpenAI Gym compatibility
  • waypoints – Extra points you would like to render over top of the the scene, for debugging
_reset(new_state=None)[source]

Resets the environment to its initial state, or a new state

Parameters:new_state (PositionState) – If specified, the environment will reset to this state
_step(action, background_simplified=False, supervisor=False)[source]

The step function accepts a control for the 0th agent in the scene. Then, it queries all the background agents to determine their actions. Then, it updates the scene and returns.

Parameters:
  • action – An action for the agentnum object in the scene.
  • agentnum (int) – The index for the object which the action is applied for.
Returns:

  • PositionState – State of the world after this step;
  • float – Reward calculated by self.reward_fn(),
  • bool – Whether we have timed out, or there is a collision)
  • dict