smarts.core.traffic_history module

class smarts.core.traffic_history.TrafficHistory(db)[source]

Traffic history for use with converted datasets.

class TrafficHistoryVehicleWindow(vehicle_id: int, vehicle_type: str, vehicle_length: float, vehicle_width: float, vehicle_height: float, start_position_x: float, start_position_y: float, start_heading: float, start_speed: float, average_speed: float, start_time: float, end_time: float, end_position_x: float, end_position_y: float, end_heading: float)[source]

General information about a vehicle between a time window.

average_speed: float

Alias for field number 9

property axle_end_position

The start position of the vehicle from the axle.

property axle_start_position

The start position of the vehicle from the axle.

property dimensions: Dimensions

The known or estimated dimensions of this vehicle.

end_heading: float

Alias for field number 14

end_position_x: float

Alias for field number 12

end_position_y: float

Alias for field number 13

end_time: float

Alias for field number 11

start_heading: float

Alias for field number 7

start_position_x: float

Alias for field number 5

start_position_y: float

Alias for field number 6

start_speed: float

Alias for field number 8

start_time: float

Alias for field number 10

vehicle_height: float

Alias for field number 4

vehicle_id: int

Alias for field number 0

vehicle_length: float

Alias for field number 2

vehicle_type: str

Alias for field number 1

vehicle_width: float

Alias for field number 3

class TrafficLightRow(sim_time: float, state: int, stop_point_x: float, stop_point_y: float, lane_id: int)[source]

Fields in a row from the TrafficLightState table.

lane_id: int

Alias for field number 4

sim_time: float

Alias for field number 0

state: int

Alias for field number 1

stop_point_x: float

Alias for field number 2

stop_point_y: float

Alias for field number 3

class TrajectoryRow(position_x: float, position_y: float, heading_rad: float, speed: float)[source]

An instant in a trajectory

heading_rad: float

Alias for field number 2

position_x: float

Alias for field number 0

position_y: float

Alias for field number 1

speed: float

Alias for field number 3

class VehicleRow(vehicle_id: int, vehicle_type: int, vehicle_length: float, vehicle_width: float, vehicle_height: float, position_x: float, position_y: float, heading_rad: float, speed: float)[source]

Vehicle state information

heading_rad: float

Alias for field number 7

position_x: float

Alias for field number 5

position_y: float

Alias for field number 6

speed: float

Alias for field number 8

vehicle_height: float

Alias for field number 4

vehicle_id: int

Alias for field number 0

vehicle_length: float

Alias for field number 2

vehicle_type: int

Alias for field number 1

vehicle_width: float

Alias for field number 3

all_vehicle_ids() Generator[int, None, None][source]

Get the ids of all vehicles in the history data

connect_for_multiple_queries()[source]

Optional optimization to avoid the overhead of parsing the sqlite file header multiple times for clients that will be performing multiple queries. If used, then disconnect() should be called when finished.

property dataset_source: str | None

The known source of the history data

decode_vehicle_type(vehicle_type: int) str[source]

Convert from the dataset type id to their config type. Options from NGSIM and INTERACTION currently include:

1=motorcycle, 2=auto, 3=truck, 4=pedestrian/bicycle This actually returns a vehicle_config_type.

disconnect()[source]

End connection with the history database.

property ego_vehicle_id: int | None

The id of the ego’s actor in the history data.

first_seen_times() Generator[Tuple[int, float], None, None][source]

Find the times each vehicle is first seen in the traffic history.

XXX: For now, limit agent missions to just passenger cars (V.type = 2)

property lane_width: float | None

The general lane width in the history data

last_seen_vehicle_time() float | None[source]

Find the time the last vehicle exits the history.

property name: str

The name of the traffic history.

random_overlapping_sample(vehicle_start_times: Dict[str, float], k: int) Set[str][source]

Grab a sample containing a subset of specified vehicles and ensure overlapping time intervals across sample.

Note: this may return a sample with less than k if we’re unable to find k overlapping.

property target_speed: float | None

The general speed limit in the history data.

traffic_light_states_between(start_time: float, end_time: float) Generator[TrafficLightRow, None, None][source]

Find all traffic light states between the given history times.

vehicle_config_type(vehicle_id: str) str[source]

Find the configuration type of the specified vehicle.

vehicle_dims(vehicle_id: str) Dimensions[source]

Get the vehicle dimensions of the specified vehicle.

vehicle_final_exit_time(vehicle_id: str) float[source]

Returns the final time the specified vehicle is seen in the history data.

vehicle_final_position(vehicle_id: str) Tuple[float, float][source]

Returns the final (x,y) position for the specified vehicle in the history data.

vehicle_ids_active_between(start_time: float, end_time: float) Generator[Tuple, None, None][source]

Find the ids of all active vehicles between the given history times.

XXX: For now, limited to just passenger cars (V.type = 2) XXX: This looks like the wrong level to filter out vehicles

vehicle_initial_time(vehicle_id: str) float[source]

Returns the initial time the specified vehicle is seen in the history data.

vehicle_pose_at_time(vehicle_id: str, sim_time: float) Tuple[float, float, float, float] | None[source]

Get the pose of the specified vehicle at the specified history time.

vehicle_trajectory(vehicle_id: str) Generator[TrajectoryRow, None, None][source]

Get the trajectory of the specified vehicle

vehicle_window_by_id(vehicle_id: str) TrafficHistoryVehicleWindow | None[source]

Find the given vehicle by its id.

vehicle_windows_in_range(exists_at_or_after: float, ends_before: float, minimum_vehicle_window: float) Generator[TrafficHistoryVehicleWindow, None, None][source]

Find all vehicles active between the given history times.

vehicles_active_between(start_time: float, end_time: float) Generator[VehicleRow, None, None][source]

Find all vehicles active between the given history times.