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
- static get_vehicle_names_from_class(vehicle_class)¶
Retrieve all vehicle names within a specified vehicle class
- initialize_from_defaults()¶
Initializes the vehicle distribution with default values
- Return type:
- remove_vehicle_classes(vehicle_classes)¶
Allows specified classes of vehicles to be removed from the vehicle distribution of the object
- remove_vehicles(vehicle_names)¶
Allows specified vehicles to be removed from the vehicle distribution of the object
- 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
- set_vehicle_weights(vehicle_weights)¶
Set specified vehicles to have a certain spawn weight in the vehicle distribution of the object