from pathlib import Path


def get_modality_from_name(sensor_path: Path):
    """Gets the modality of a sensor from its name.

    Args:
        sensor_path (Path): the Path of the sensor. Ex: CAM_FRONT_RIGHT, LIDAR_TOP, etc.

    Returns:
        str: the sensor modality
    """
    sensor_name_str = str(sensor_path)

    if "CAM" in sensor_name_str:
        return "camera"
    elif "RADAR" in sensor_name_str:
        return "radar"
    elif "LIDAR" in sensor_name_str:
        return "lidar"
    else:
        return "unknown"