smarts.core.vehicle_index module

class smarts.core.vehicle_index.VehicleIndex[source]

A vehicle management system that associates owners with vehicles.

agent_vehicle_ids

A caching decorator.

attach_sensors_to_vehicle(sim: SMARTS, vehicle_id: str, agent_interface: AgentInterface, plan: plan.Plan)[source]

Attach sensors as per the agent interface requirements to the specified vehicle.

begin_rendering_vehicles(renderer: RendererBase)[source]

Render vehicles using the specified renderer.

build_agent_vehicle(sim: SMARTS, agent_id: str, agent_interface: AgentInterface, plan: plan.Plan, trainable: bool, initial_speed: float | None = None, boid: bool = False, *, vehicle_id: str | None = None) Vehicle[source]

Build an entirely new vehicle for an agent.

build_social_vehicle(sim: SMARTS, vehicle_state: VehicleState, owner_id: str, vehicle_id: str | None = None) Vehicle[source]

Build an entirely new vehicle for a social agent.

controller_state_for_vehicle_id

A caching decorator.

classmethod identity()[source]

Returns an empty identity index.

load_vehicle_definitions_list(vehicle_definitions_filepath: str)[source]

Loads in a list of vehicle definitions.

owner_id_from_vehicle_id

A caching decorator.

relinquish_agent_control(sim: SMARTS, vehicle_id: str, road_map: RoadMap) Tuple[VehicleState, RoadMap.Route | None][source]

Give control of the vehicle back to its original controller.

shadower_id_from_vehicle_id

A caching decorator.

shadower_ids

A caching decorator.

social_vehicle_ids

A caching decorator.

start_agent_observation(sim: SMARTS, vehicle_id: str, agent_id: str, agent_interface: AgentInterface, plan: plan.Plan, boid: bool = False, initialize_sensors: bool = True)[source]

Associate an agent to a vehicle. Set up any needed sensor requirements.

stop_agent_observation(vehicle_id: str) Vehicle[source]

Strip all sensors from a vehicle and stop all owners from watching the vehicle.

stop_shadowing(shadower_id: str, vehicle_id: str | None = None)[source]

Ends the shadowing by an a shadowing observer.

Parameters:
  • shadower_id (str) – Removes this shadowing observer from all vehicles.

  • vehicle_id (str, optional) – If given this method removes shadowing from a specific vehicle. Defaults to None.

switch_control_to_agent(sim: SMARTS, vehicle_id: str, agent_id: str, boid: bool = False, hijacking: bool = False, recreate: bool = False, agent_interface: AgentInterface | None = None)[source]

Give control of the specified vehicle to the specified agent. :param sim: An instance of a SMARTS simulation. :param vehicle_id: The id of the vehicle to associate. :param agent_id: The id of the agent to associate. :param boid: If the agent is acting as a boid agent controlling multiple vehicles. :param hijacking: If the vehicle has been taken over from another controlling owner. :param recreate: If the vehicle should be destroyed and regenerated. :param agent_interface: The agent interface for sensor requirements.

sync()[source]

Update the state of the index.

teardown(renderer: RendererBase)[source]

Clean up resources, resetting the index.

teardown_vehicles_by_owner_ids(owner_ids: Iterable[str], renderer: RendererBase, include_shadowing: bool = True) List[str][source]

Terminate and remove all vehicles associated with an owner id.

teardown_vehicles_by_vehicle_ids(vehicle_ids: Sequence[str], renderer: RendererBase | None)[source]

Terminate and remove a vehicle from the index using its id.

vehicle_by_id

A caching decorator.

vehicle_ids

A caching decorator.

vehicle_ids_by_owner_id

A caching decorator.

vehicle_is_hijacked(vehicle_id: str) bool[source]

Determine if a vehicle is controlled by an owner.

vehicle_is_hijacked_or_shadowed

A caching decorator.

vehicle_is_shadowed(vehicle_id: str) bool[source]

Determine if a vehicle is watched by an owner.

vehicle_position

A caching decorator.

vehicleitems

A caching decorator.

property vehicles: List[Vehicle]

A list of all existing vehicles.

vehicles_by_owner_id(owner_id: str, include_shadowers: bool = False)[source]

Find vehicles associated with the given owner id. :param owner_id: The owner id to find all associated vehicle ids. :param include_shadowers: If to include vehicles that the owner is only watching.

Returns:

A list of associated vehicles.