def METHOD_NAME(sensor):
    """Return the distance of an obstacle for a sensor."""
    # Special case, when the sensor doesn't detect anything, we use an
    # infinite distance.
    if sensor.getValue() == 0:
        return float("inf")
    return 5.0 * (1.0 - sensor.getValue() / 1024.0)