ast_toolbox.simulators.example_av_simulator.example_av_simulator module

Example simulator wrapper for a scenario of an AV approaching a crosswalk where some pedestrians are crossing.

class ast_toolbox.simulators.example_av_simulator.example_av_simulator.ExampleAVSimulator(num_peds=1, simulator_args=None, **kwargs)[source]

Bases: ast_toolbox.simulators.ast_simulator.ASTSimulator

Example simulator wrapper for a scenario of an AV approaching a crosswalk where some pedestrians are crossing.

Wraps ast_toolbox.simulators.example_av_simulator.ToyAVSimulator

Parameters:
  • num_peds (int) – Number of pedestrians crossing the street.
  • simulator_args (dict) – Dictionary of keyword arguments to be passed to the wrapped simulator.
  • kwargs – Keyword arguments passed to the super class.
clone_state()[source]

Clone the simulator state for later resetting.

This function is used in conjunction with restore_state for Go-Explore and Backwards Algorithm to do their deterministic resets.

Returns:array_like – An array of all the simulation state variables.
closed_loop_step(action)[source]

User implemented function to step the simulation forward in time when closed-loop control is active.

This function should step the simulator forward a single timestep based on the given action. It will only be called when open_loop is False. This function should always return self.observation_return().

Parameters:action (array_like) – A 1-D array of actions taken by the AST Solver which deterministically control a single step forward in the simulation.
Returns:array_like – An observation from the timestep, determined by the settings and the observation_return helper function.
get_first_action()[source]

An initialization method used in Go-Explore.

Returns:array_like – A 1-D array of the same dimension as the action space, all zeros.
get_reward_info()[source]

Returns any info needed by the reward function to calculate the current reward.

is_goal()[source]

Returns whether the current state is in the goal set. :returns: bool – True if current state is in goal set.

log()[source]

Perform any logging steps.

reset(s_0)[source]

Resets the state of the environment, returning an initial observation.

User implementations should always call the super class implementation. This function should always return self.observation_return().

Parameters:s_0 (array_like) – The initial conditions to reset the simulator to.
Returns:array_like – An observation from the timestep, determined by the settings and the observation_return helper function.
restore_state(in_simulator_state)[source]

Reset the simulation deterministically to a previously cloned state.

This function is used in conjunction with clone_state for Go-Explore and Backwards Algorithm to do their deterministic resets.

Parameters:in_simulator_state (array_like) – An array of all the simulation state variables.
simulate(actions, s_0)[source]

Run a full simulation given the AST solver’s actions and initial conditions.

simulate takes in the AST solver’s actions and the initial conditions. It should return two values: a terminal index and an array of relevant simulation information.

Parameters:
  • actions (list[array_like]) – A sequential list of actions taken by the AST Solver which deterministically control the simulation.
  • s_0 (array_like) – An array specifying the initial conditions to set the simulator to.
Returns:

  • terminal_index (int) – The index of the action that resulted in a state in the goal set E. If no state is found terminal_index should be returned as -1.
  • array_like – An array of relevant simulator info, which can then be used for analysis or diagnostics.