smarts.core.local_traffic_provider module

class smarts.core.local_traffic_provider.LocalTrafficProvider[source]

A LocalTrafficProvider simulates multiple traffic actors on a generic RoadMap.

property actions: Set[ActionSpaceType]

The action spaces of the provider.

add_actor(provider_actor: ActorState, from_provider: Provider | None = None)[source]

Management of the actor with state is being assigned (or transferred if from_provider is not None) to this Provider. Should only be called if can_accept_actor() has returned True.

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.

destroy()[source]

Clean up any connections/resources.

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)[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.

reset()[source]

Reset this provider to a pre-initialized state.

route_for_vehicle(vehicle_id: str) Route | None[source]

Gets the current Route for the specified vehicle, if known.

set_manager(manager: ProviderManager)[source]

Indicate the manager that this provider should inform of all actor hand-offs.

setup(scenario: smarts.core.scenario.Scenario) ProviderState[source]

Initialize the provider with a scenario.

step(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:

ProviderState

stop_managing(actor_id: str)[source]

Tells the Provider to stop managing the specified actor; it will be managed by another Provider now.

sync(provider_state: ProviderState)[source]

Synchronize with state managed by other Providers.

teardown()[source]

Clean up provider resources.

update_route_for_vehicle(vehicle_id: str, new_route: Route)[source]

Set a new route for the given vehicle.

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.