class IQServiceConfig(BaseDenseServiceConfig):
    class SamplingMode(ConfigEnum):
        A = ("A (less correlation)", 0)
        B = ("B (more SNR)", 1)

    mode = ModeParameter(
        label="Mode",
        value=Mode.IQ,
    )

    sampling_mode = cb.EnumParameter(
        label="Sampling mode",
        enum=SamplingMode,
        default_value=SamplingMode.A,
        order=1000,
        category=cb.Category.ADVANCED,
    )

    depth_lowpass_cutoff_ratio = cb.FloatParameter(
        label="Depth LPF cutoff ratio",
        default_value=None,
        limits=(0.0, 0.5),
        decimals=6,
        optional=True,
        optional_default_set_value=0.5,
        optional_label="Override",
        order=2100,
        category=cb.Category.ADVANCED,
        help=r"""
            Depth domain lowpass filter cutoff frequency ratio

            The cutoff for the depth domain lowpass filter is specified as the ratio between the
            spatial frequency cutoff and the sample frequency. A ratio of zero ratio will configure
            the smoothest possible filter. A ratio of 0.5 (the Nyquist frequency) turns the filter
            off.

            If unset, i.e., if not overridden, the ratio will be chosen automatically. The used
            ratio is returned in the session information (metadata) upon session setup (create).
        """,
    )

    _depth_lowpass_cutoff_ratio_value = cb.get_virtual_parameter_class(cb.FloatParameter)(
        label="Depth LPF cutoff ratio value",
        get_fun=lambda conf: utils.optional_or_else(conf.depth_lowpass_cutoff_ratio, 0.0),
        visible=False,
    )

    _depth_lowpass_cutoff_ratio_override = cb.get_virtual_parameter_class(cb.BoolParameter)(
        label="Depth LPF cutoff ratio override",
        get_fun=lambda conf: conf.depth_lowpass_cutoff_ratio is not None,
        visible=False,
    )

    def check(self):
        alerts = super().check()

        if self.range_start < (0.06 - 1e-6):
            alerts.append(cb.Error("range_interval", "Start must be >= 0.06 m"))

        return alerts
예제 #2
0
class BaseServiceConfig(BaseSessionConfig):
    class RepetitionMode(ConfigEnum):
        HOST_DRIVEN = ("Host driven", "on_demand")
        SENSOR_DRIVEN = ("Sensor driven", "streaming")

    class Profile(ConfigEnum):
        PROFILE_1 = ("1 (max resolution)", 1, 0.10)
        PROFILE_2 = ("2", 2, 0.12)
        PROFILE_3 = ("3", 3, 0.18)
        PROFILE_4 = ("4", 4, 0.36)
        PROFILE_5 = ("5 (max SNR)", 5, 0.60)

        @property
        def approx_direct_leakage_length(self):
            return self.value[2]

    class PowerSaveMode(ConfigEnum):
        ACTIVE = ("Active", "active")
        READY = ("Ready", "ready")
        SLEEP = ("Sleep", "sleep")
        OFF = ("Off", "off")

    range_interval = cb.FloatRangeParameter(
        label="Range interval",
        unit="m",
        default_value=[0.18, 0.78],
        limits=(-0.7, 7.0),
        order=10,
        help=r"""
            The measured depth range. The start and end values will be rounded to the closest
            measurement point available.
        """,
    )

    range_start = cb.get_virtual_parameter_class(cb.FloatParameter)(
        label="Range start",
        get_fun=lambda conf: conf.range_interval[0],
        visible=False,
    )

    range_length = cb.get_virtual_parameter_class(cb.FloatParameter)(
        label="Range length",
        get_fun=lambda conf: conf.range_interval[1] - conf.range_interval[0],
        visible=False,
    )

    range_end = cb.get_virtual_parameter_class(cb.FloatParameter)(
        label="Range end",
        get_fun=lambda conf: conf.range_interval[1],
        visible=False,
    )

    repetition_mode = cb.EnumParameter(
        label="Repetition mode",
        enum=RepetitionMode,
        default_value=RepetitionMode.HOST_DRIVEN,
        order=1010,
        category=cb.Category.ADVANCED,
        help=r"""
            The RSS supports two different repetition modes. They determine how and when data
            acquisition occurs. They are:

            * **On demand / host driven**: The sensor produces data when requested by the
              application. Hence, the application is responsible for timing the data acquisition.
              This is the default mode, and may be used with all power save modes.

            * **Streaming / sensor driven**: The sensor produces data at a fixed rate, given by a
              configurable accurate hardware timer. This mode is recommended if exact timing
              between updates is required.

            The Exploration Tool is capable of setting the update rate also in *on demand (host
            driven)* mode. Thus, the difference between the modes becomes subtle. This is why *on
            demand* and *streaming* are called *host driven* and *sensor driven* respectively in
            Exploration Tool.
        """,
    )

    update_rate = cb.FloatParameter(
        label="Update rate",
        unit="Hz",
        default_value=None,
        limits=(0.1, None),
        decimals=1,
        optional=True,
        optional_label="Limit",
        optional_default_set_value=50.0,
        order=30,
        help=r"""
            The rate :math:`f_f` at which the sensor sends frames to the host MCU.

            .. attention::

               Setting the update rate too high might result in missed data frames.

            In sparse, the maximum possible update rate depends on the *sweeps per frame*
            :math:`N_s` and *sweep rate* :math:`f_s`:

            .. math::

               \frac{1}{f_f} > N_s \cdot \frac{1}{f_s} + \text{overhead*}

            \* *The overhead largely depends on data frame size and data transfer speeds.*
        """,
    )

    gain = cb.FloatParameter(
        label="Gain",
        default_value=0.5,
        limits=(0.0, 1.0),
        decimals=2,
        order=1040,
        category=cb.Category.ADVANCED,
        help=r"""
            The receiver gain used in the sensor. If the gain is too low, objects may not be
            visible, or it may result in poor signal quality due to quantization errors. If the
            gain is too high, strong reflections may result in saturated data. We recommend not
            setting the gain higher than necessary due to signal quality reasons.

            Must be between 0 and 1 inclusive, where 1 is the highest possible gain.

            .. note::
               When Sensor normalization is active, the change in the data due to changing gain is
               removed after normalization. Therefore, the data might seen unaffected by changes
               in the gain, except very high (receiver saturation) or very low (quantization
               error) gain.

               Sensor normalization is not available for the Sparse service, but is enabled by
               default for the other services - Envelope, IQ, and Power Bins.
        """,
    )

    hw_accelerated_average_samples = cb.IntParameter(
        label="HW accel. average samples",
        default_value=10,
        limits=(1, 63),
        order=1030,
        category=cb.Category.ADVANCED,
        help=r"""
            Number of samples taken to obtain a single point in the data. These are averaged
            directly in the sensor hardware - no extra computations are done in the MCU.

            The time needed to measure a sweep is roughly proportional to the HWAAS. Hence, if
            there's a need to obtain a higher sweep rate, HWAAS could be decreased. Note that
            HWAAS does not affect the amount of data transmitted from the sensor over SPI.

            Must be at least 1 and not greater than 63.
        """,
    )

    maximize_signal_attenuation = cb.BoolParameter(
        label="Max signal attenuation",
        default_value=False,
        order=2000,
        category=cb.Category.ADVANCED,
        help=r"""
            When measuring in the direct leakage (around 0m), this setting can be enabled to
            minimize saturation in the receiver. We do not recommend using this setting under
            normal operation.
        """,
    )

    profile = cb.EnumParameter(
        label="Profile",
        enum=Profile,
        default_value=Profile.PROFILE_2,
        order=20,
        help=r"""
            The main configuration of all the services are the profiles, numbered 1 to 5. The
            difference between the profiles is the length of the radar pulse and the way the
            incoming pulse is sampled. Profiles with low numbers use short pulses while the higher
            profiles use longer pulses.

            Profile 1 is recommended for:

            - measuring strong reflectors, to avoid saturation of the received signal
            - close range operation (<20 cm), due to the reduced direct leakage

            Profile 2 and 3 are recommended for:

            - operation at intermediate distances, (20 cm to 1 m)
            - where a balance between SNR and depth resolution is acceptable

            Profile 4 and 5 are recommended for:

            - for Sparse service only
            - operation at large distances (>1 m)
            - motion or presence detection, where an optimal SNR ratio is preferred over a high
              resolution distance measurement

            The previous profile Maximize Depth Resolution and Maximize SNR are now profile 1 and
            2. The previous Direct Leakage Profile is obtained by the use of the Maximize Signal
            Attenuation parameter.
        """,
    )

    downsampling_factor = cb.IntParameter(
        label="Downsampling factor",
        default_value=1,
        limits=(1, None),
        order=1020,
        category=cb.Category.ADVANCED,
        help=r"""
            The range downsampling by an integer factor. A factor of 1 means no downsampling, thus
            sampling with the smallest possible depth interval. A factor 2 samples every other
            point, and so on. In Envelope and IQ, the finest interval is ~0.5 mm. In Power Bins,
            it is the same but then further downsampled in post-processing.
            In sparse, it is ~6 cm.

            The downsampling is performed by skipping measurements in the sensor, and therefore
            gives lower memory usage, lower power consumption, and lower duty cycle.

            In sparse, setting a too large factor might result in gaps in the data where moving
            objects "disappear" between sampling points.

            In Envelope, IQ, and Power Bins, the factor must be 1, 2, or 4.
            In sparse, it must be at least 1.
            Setting a factor greater than 1 might affect the range end point and for IQ and
            Envelope, also the first point.
        """,
    )

    tx_disable = cb.BoolParameter(
        label="Disable TX",
        default_value=False,
        order=3000,
        category=cb.Category.ADVANCED,
        help=r"""
            Disable the radio transmitter. If used to measure noise, we recommended also switching
            off noise level normalization (if applicable).
        """,
    )

    power_save_mode = cb.EnumParameter(
        label="Power save mode",
        enum=PowerSaveMode,
        default_value=PowerSaveMode.ACTIVE,
        order=3100,
        category=cb.Category.ADVANCED,
    )

    def check(self):
        alerts = []

        if self.repetition_mode == __class__.RepetitionMode.SENSOR_DRIVEN:
            if self.update_rate is None:
                alerts.append(
                    cb.Error("update_rate", "Must be set when sensor driven"))

        if self.gain > 0.9:
            alerts.append(
                cb.Warning("gain", "Too high gain causes degradation"))

        if self.range_start < self.profile.approx_direct_leakage_length:
            alerts.append(
                cb.Info("range_interval", "Direct leakage might be seen"))

        return alerts
예제 #3
0
class ProcessingConfiguration(cb.ProcessingConfig):
    VERSION = 1
    WINDOW_SIZE_POW_OF_2_MAX = 12
    ROLLING_HISTORY_SIZE_MAX = 1000

    show_time_domain = cb.BoolParameter(
        label="Show data in time domain",
        default_value=True,
        updateable=True,
        order=0,
    )

    show_spect_history = cb.BoolParameter(
        label="Show spectrum history",
        default_value=False,
        updateable=True,
        order=10,
    )

    show_depthwise_spect = cb.BoolParameter(
        label="Show depthwise spectrum",
        default_value=False,
        updateable=True,
        order=20,
    )

    window_size_pow_of_2 = cb.FloatParameter(
        label="Window size, power of 2",
        default_value=8,
        limits=(3, WINDOW_SIZE_POW_OF_2_MAX),
        decimals=0,
        updateable=True,
        order=100,
    )

    _window_size = cb.get_virtual_parameter_class(cb.IntParameter)(
        label="Window size",
        get_fun=lambda conf: 2**int(conf.window_size_pow_of_2),
        visible=False,
    )

    overlap = cb.FloatParameter(
        label="Overlap",
        default_value=0.95,
        limits=(0, 1),
        updateable=True,
        order=200,
    )

    rolling_history_size = cb.FloatParameter(
        label="Rolling history size",
        default_value=100,
        decimals=0,
        logscale=True,
        limits=(10, ROLLING_HISTORY_SIZE_MAX),
        updateable=True,
        order=300,
    )

    def check(self):
        alerts = super().check()

        msg = "{}".format(self._window_size)
        alerts.append(cb.Info("window_size_pow_of_2", msg))

        return alerts