paralleldomain.data_lab.utilities.vehicle_distribution_builder

class VehicleDistributionBuilder

Helper class for building vehicle distributions compatible with PD SDK, and Data Lab

Note

The class takes no parameters on initialization and loads the default vehicle distribution on initialization

Examples:

>>> builder = VehicleDistributionBuilder()
>>> builder.initialize_from_defaults()
>>> builder.set_vehicle_class_weights({"BUS": 10.0})
>>> scenario.add_agents(
>>>     generator=ParkedVehicleGeneratorParameters(
>>>         spawn_probability=CenterSpreadConfig(center=0.99),
>>>         position_request=PositionRequest(
>>>             location_relative_position_request=LocationRelativePositionRequest(
>>>                 agent_tags=["EGO"],
>>>                 max_spawn_radius=100.0,
>>>             )
>>>         ),
>>>         vehicle_distribution=builder.get_configuration(),
>>>     )
>>> )
Raises:

PdError – If the Data Lab context is invalid or not setup. Ensure setup_datalab() has been called prior

get_configuration()

Retrieves the vehicle distribution in the object in a format directly digestible by Data Lab

Return type:

Dict[str, VehicleCategoryWeight]

Returns:

A dictionary representation of the created vehicle distribution outlining the spawn weights of each vehicle

class and the spawn weights of specific vehicles within each class

static get_vehicle_names_from_class(vehicle_class)

Retrieve all vehicle names within a specified vehicle class

Parameters:

vehicle_class (str) – The name of the vehicle class within which we wish to find all vehicle names

Return type:

List[str]

Returns:

A list of all vehicle names within the specified class

initialize_from_defaults()

Initializes the vehicle distribution with default values

Return type:

None

remove_vehicle_classes(vehicle_classes)

Allows specified classes of vehicles to be removed from the vehicle distribution of the object

Parameters:

vehicle_classes (Iterable[str]) – The names of the classes of vehicles to be removed from the vehicle distribution

Return type:

None

remove_vehicles(vehicle_names)

Allows specified vehicles to be removed from the vehicle distribution of the object

Parameters:

vehicle_names (Iterable[str]) – The names of the vehicles to be removed from the vehicle distribution

Return type:

None

set_vehicle_class_weights(class_weights)

Set specified vehicle classes to have a certain spawn weight in the vehicle distribution of the object :rtype: None

Args:
class_weights: Dictionary containing the name of the vehicles classes and their respective weights

to be added or modified in the vehicle distribution of the object

Parameters:

class_weights (Dict[str, float]) –

Return type:

None

set_vehicle_weights(vehicle_weights)

Set specified vehicles to have a certain spawn weight in the vehicle distribution of the object

Parameters:

vehicle_weights (Dict[str, float]) – Dictionary containing the name of the vehicles and their respective weights to be added or modified in the vehicle distribution of the object

Return type:

None

property class_weights: Dict[str, float]

Dictionary containing the assigned weights of each of the vehicle classes

property vehicle_weights: Dict[str, float]

Dictionary containing the assigned weights of each vehicle