data_gathering.car_detection_matrix package

Submodules

data_gathering.car_detection_matrix.run_matrix module

class data_gathering.car_detection_matrix.run_matrix.DetectionMatrix(ego_vehicle: carla.Actor, world: carla.World, road_lane_ids: Set[RoadLaneId] | None = None)

Bases: object

Create a matrix representing the lanes around the ego vehicle.

Parameters:
__init__(ego_vehicle: carla.Actor, world: carla.World, road_lane_ids: Set[RoadLaneId] | None = None)
Parameters:
running

If the matrix will perform updates.

matrix: Dict[int, List[int]]

An ordered dictionary representing the city matrix. The keys for existing lanes are the lane IDs in the format “road_id_lane_id”. For non-existing lanes different placeholder exist, e.g. left_outer_lane, left_inner_lane, No_4th_lane, No_opposing_direction The values indicate whether a vehicle is present: 0 - No vehicle, 1 - Ego vehicle, 3 - No road. Format example:

{
    "left_outer_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "left_inner_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "1_2": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_1": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_-1": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_-2": [0, 0, 0, 0, 0, 0, 0, 0],
    "right_inner_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "right_outer_lane": [3, 3, 3, 3, 3, 3, 3, 3],
}

Attention

Currently the keys are replaces by numbers.

Type:

A collections.OrderedDict

update() Dict[int, List[int]] | None

If the matrix is running, it will update the matrix and return it, otherwise returns None.

Return type:

Dict[int, List[int]] | None

getMatrix() Dict[int, List[int]]
Return type:

Dict[int, List[int]]

start()

Allows the matrix to update.

stop()

Prevents the matrix from updating.

to_list() None | list[list[int]]

Returns the values of matrix as a list.

Return type:

None | list[list[int]]

to_numpy() None | np.ndarray[int, Any]

Returns the values of matrix as a numpy array.

Return type:

None | np.ndarray[int, Any]

class data_gathering.car_detection_matrix.run_matrix.AsyncDetectionMatrix(ego_vehicle: carla.Actor, world: carla.World, road_lane_ids=None, *, sleep_time=0.1)

Bases: DetectionMatrix

Parameters:
__init__(ego_vehicle: carla.Actor, world: carla.World, road_lane_ids=None, *, sleep_time=0.1)

Asynchronous version of the DetectionMatrix.

Will calculate the matrix update in a separate thread.

Parameters:
to_list() None | list[list[int]]

Returns the values of matrix as a list.

Return type:

None | list[list[int]]

to_numpy() None | np.ndarray[int, Any]

Returns the values of matrix as a numpy array.

Return type:

None | np.ndarray[int, Any]

matrix: Dict[int, List[int]]

An ordered dictionary representing the city matrix. The keys for existing lanes are the lane IDs in the format “road_id_lane_id”. For non-existing lanes different placeholder exist, e.g. left_outer_lane, left_inner_lane, No_4th_lane, No_opposing_direction The values indicate whether a vehicle is present: 0 - No vehicle, 1 - Ego vehicle, 3 - No road. Format example:

{
    "left_outer_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "left_inner_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "1_2": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_1": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_-1": [0, 0, 0, 0, 0, 0, 0, 0],
    "1_-2": [0, 0, 0, 0, 0, 0, 0, 0],
    "right_inner_lane": [3, 3, 3, 3, 3, 3, 3, 3],
    "right_outer_lane": [3, 3, 3, 3, 3, 3, 3, 3],
}

Attention

Currently the keys are replaces by numbers.

Type:

A collections.OrderedDict

running

If the matrix will perform updates.

update() None

Not available in the async version.

Return type:

None

getMatrix()
start()

Allows the matrix to update.

stop()

Prevents the matrix from updating.