def load_lidar_configuration()

in deepracer_follow_the_leader_ws/webserver_pkg/webserver_pkg/models.py [0:0]


def load_lidar_configuration(sensors, data):
    """Helper method to load the LiDAR configuration data if present in the model_metadata.json
       file of the data.

    Args:
        sensors (list): List of SensorInputKeys enum objects which the model was trained on.
        data (dict): JSON data with the content read from model_metadata.json of the model.

    Returns:
        tuple: A tuple of error code, error message and the LiDAR configuration dictionary.
    """
    webserver_node = webserver_publisher_node.get_webserver_node()
    try:
        # Set default values in case the "lidar configuration" is not
        # defined in model_metadata.json.
        model_lidar_config = constants.DEFAULT_LIDAR_CONFIG
        # Set default values for SECTOR_LIDAR if this sensor is used
        if constants.SensorInputKeys.SECTOR_LIDAR in sensors:
            model_lidar_config = constants.DEFAULT_SECTOR_LIDAR_CONFIG
        model_lidar_config[
            constants.ModelMetadataKeys.USE_LIDAR
        ] = sensors and (constants.SensorInputKeys.LIDAR in sensors
                         or constants.SensorInputKeys.SECTOR_LIDAR in sensors)
        # Load the lidar configuration if the model uses lidar and has custom
        # lidar configurations.
        if model_lidar_config[constants.ModelMetadataKeys.USE_LIDAR] \
           and constants.ModelMetadataKeys.LIDAR_CONFIG in data:
            lidar_config = data[constants.ModelMetadataKeys.LIDAR_CONFIG]
            model_lidar_config[
                constants.ModelMetadataKeys.NUM_LIDAR_VALUES
            ] = lidar_config[constants.ModelMetadataKeys.NUM_LIDAR_VALUES]
            model_lidar_config[
                constants.ModelMetadataKeys.MIN_LIDAR_ANGLE
            ] = lidar_config[constants.ModelMetadataKeys.MIN_LIDAR_ANGLE]
            model_lidar_config[
                constants.ModelMetadataKeys.MAX_LIDAR_ANGLE
            ] = lidar_config[constants.ModelMetadataKeys.MAX_LIDAR_ANGLE]
            model_lidar_config[
                constants.ModelMetadataKeys.MIN_LIDAR_DIST
            ] = lidar_config[constants.ModelMetadataKeys.MIN_LIDAR_DIST]
            model_lidar_config[
                constants.ModelMetadataKeys.MAX_LIDAR_DIST
            ] = lidar_config[constants.ModelMetadataKeys.MAX_LIDAR_DIST]
            model_lidar_config[
                constants.ModelMetadataKeys.LIDAR_CLIPPING_DIST
            ] = lidar_config[constants.ModelMetadataKeys.LIDAR_CLIPPING_DIST]
            model_lidar_config[
                constants.ModelMetadataKeys.NUM_LIDAR_SECTORS
            ] = lidar_config[constants.ModelMetadataKeys.NUM_LIDAR_SECTORS]
        return 0, "", model_lidar_config
    except Exception as ex:
        webserver_node.get_logger().error("Unable to connect to vehicle with current "
                                          f"LiDAR configuration: {ex}")
        return 1, "Unable to connect to vehicle with current LiDAR configuration", {}