smarts.core.traffic_history_provider module
- class smarts.core.traffic_history_provider.TrafficHistoryProvider[source]
A provider that replays traffic history for simulation.
- property actions: Set[ActionSpaceType]
The action spaces of the provider.
- can_accept_actor(state: ActorState) bool [source]
Whether this Provider can take control of an existing actor with state that was previously managed by another Provider. The state.role field should indicate the desired role, not the previous role.
- property done_this_step
The vehicles that are to be removed this step.
- property history_vehicle_ids: Set[str]
Actor IDs for all history vehicles.
- manages_actor(actor_id: str) bool [source]
Returns True if the actor referenced by actor_id is managed by this Provider.
- property recovery_flags: ProviderRecoveryFlags
Flags specifying what this provider should do if it fails. (May be overridden by child classes.)
- reserve_traffic_location_for_vehicle(vehicle_id: str, reserved_location: Polygon)[source]
Reserve an area around a location where vehicles cannot spawn until a given vehicle is added. :param vehicle_id: The vehicle to wait for. :param reserved_location: The space the vehicle takes up.
- set_manager(manager: ProviderManager)[source]
Indicate the manager that this provider should inform of all actor hand-offs.
- set_replaced_ids(actor_ids: Iterable[str])[source]
Replace the given vehicles, excluding them from control by this provider.
- setup(scenario) ProviderState [source]
Initialize this provider with the given scenario.
- property start_time
The start time of the traffic playback
- step(provider_actions, dt: float, elapsed_sim_time: float) ProviderState [source]
Progress the provider to generate new actor state. :param actions: one or more valid actions from the supported action_spaces of this provider :param dt: time (in seconds) to simulate during this simulation step :type dt: float :param elapsed_sim_time: amount of time (in seconds) that’s elapsed so far in the simulation :type elapsed_sim_time: float
- Returns:
State representation of all actors this manages.
- Return type:
- stop_managing(actor_id: str)[source]
Tells the Provider to stop managing the specified actor; it will be managed by another Provider now.
- vehicle_collided(vehicle_id: str)[source]
Called when a vehicle this provider manages is detected to have collided with any other vehicles in the scenario.
- vehicle_dest_road(vehicle_id: str) str | None [source]
Get the final road_id in the route of the given vehicle.
- vehicle_history_window(vehicle_id: str) TrafficHistoryVehicleWindow [source]
Retrieves vehicle history in the specified time window.
- Parameters:
vehicle_id (str) – Id of vehicle of interest.
- Raises:
ValueError – If vehicle_id is not present in traffic history.
- Returns:
- Vehicle history in the
specified time window.
- Return type: