def __init__(self, sensor_config, processing_config, session_info):
        self.sensor_config = sensor_config
        self.processing_config = processing_config

        self.depths = utils.get_range_depths(sensor_config, session_info)
        self.depth_res = session_info["step_length_m"]
        self.smooth_max = utils.SmoothMax(sensor_config.update_rate)
    def setup(self, win):
        win.resize(800, 600)
        win.setWindowTitle("Acconeer sleep breathing estimation example")

        phi_title = "Breathing motion (detection range: {} m to {} m)" \
                    .format(*self.config.range_interval)
        self.phi_plot = win.addPlot(title=phi_title)
        self.phi_plot.setMenuEnabled(False)
        self.phi_plot.showGrid(x=True, y=True)
        self.phi_plot.setLabel("left", "Amplitude")
        self.phi_plot.setLabel("bottom", "Samples")
        self.phi_plot.addLegend()
        self.filt_phi_curve = self.phi_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Filtered",
        )
        self.raw_phi_curve = self.phi_plot.plot(
            pen=utils.pg_pen_cycler(1),
            name="Raw",
        )

        win.nextRow()

        self.spect_plot = win.addPlot(title="Power spectrum")
        self.spect_plot.setMenuEnabled(False)
        self.spect_plot.showGrid(x=True, y=True)
        self.spect_plot.setLabel("left", "Power")
        self.spect_plot.setLabel("bottom", "Frequency (Hz)")
        self.spect_curve = self.spect_plot.plot(pen=utils.pg_pen_cycler(1))
        self.spect_smax = utils.SmoothMax(self.config.update_rate / 15)
        self.spect_dft_inf_line = pg.InfiniteLine(pen=utils.pg_pen_cycler(1, "--"))
        self.spect_plot.addItem(self.spect_dft_inf_line)
        self.spect_est_inf_line = pg.InfiniteLine(pen=utils.pg_pen_cycler(0, "--"))
        self.spect_plot.addItem(self.spect_est_inf_line)
        self.spect_plot.setXRange(0, 1)
        self.spect_plot.setYRange(0, 1)
        self.spect_text_item = pg.TextItem("Initiating...", anchor=(0.5, 0.5), color="k")
        self.spect_text_item.setPos(0.5, 0.5)
        self.spect_plot.addItem(self.spect_text_item)

        win.nextRow()
        self.fest_plot = win.addPlot(title="Breathing estimation history")
        self.fest_plot.setMenuEnabled(False)
        self.fest_plot.showGrid(x=True, y=True)
        self.fest_plot.setLabel("left", "Frequency (Hz)")
        self.fest_plot.setLabel("bottom", "Samples")
        self.fest_plot.addLegend()
        self.fest_curve = self.fest_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Breathing est.",
        )
        self.fest_dft_curve = self.fest_plot.plot(
            pen=utils.pg_pen_cycler(1),
            name="DFT est.",
        )
        self.fest_plot.setXRange(0, 1)
        self.fest_plot.setYRange(0, 0.5)
        self.fest_text_item = pg.TextItem(anchor=(0, 0), color="k")
        self.fest_text_item.setPos(0, 0.5)
        self.fest_plot.addItem(self.fest_text_item)
Exemplo n.º 3
0
    def setup(self, win):
        win.setWindowTitle("Acconeer IQ example")

        self.ampl_plot = win.addPlot()
        self.ampl_plot.setMenuEnabled(False)
        self.ampl_plot.showGrid(x=True, y=True)
        self.ampl_plot.setLabel("bottom", "Depth (m)")
        self.ampl_plot.setLabel("left", "Amplitude")
        win.nextRow()
        self.phase_plot = win.addPlot()
        self.phase_plot.setMenuEnabled(False)
        self.phase_plot.showGrid(x=True, y=True)
        self.phase_plot.setLabel("bottom", "Depth (m)")
        self.phase_plot.setLabel("left", "Phase")
        self.phase_plot.setYRange(-np.pi, np.pi)
        self.phase_plot.getAxis("left").setTicks(utils.pg_phase_ticks)

        self.ampl_curves = []
        self.phase_curves = []
        for i, _ in enumerate(self.sensor_config.sensor):
            pen = utils.pg_pen_cycler(i)
            self.ampl_curves.append(self.ampl_plot.plot(pen=pen))
            self.phase_curves.append(self.phase_plot.plot(pen=pen))

        self.smooth_max = utils.SmoothMax(self.sensor_config.update_rate)
Exemplo n.º 4
0
    def __init__(self, sensor_config, processing_config, session_info):
        assert sensor_config.update_rate is not None

        f = sensor_config.update_rate
        self.depths = utils.get_range_depths(sensor_config, session_info)
        self.hist_plot_len_s = processing_config.hist_plot_len
        self.hist_plot_len = int(round(self.hist_plot_len_s * f))
        self.move_xs = (np.arange(-self.hist_plot_len, 0) + 1) / f
        self.smooth_max = utils.SmoothMax(f, hysteresis=0.4, tau_decay=1.5)
Exemplo n.º 5
0
    def __init__(self, sensor_config, processing_config, session_info):
        self.processing_config = processing_config

        self.f = sensor_config.update_rate
        self.depths = utils.get_range_depths(sensor_config, session_info)
        self.downsampling_factor = sensor_config.downsampling_factor
        self.step_length = session_info["step_length_m"]

        self.td_smooth_lims = utils.SmoothLimits()
        self.collapsed_smooth_max = utils.SmoothMax(tau_grow=0.1, )

        self.setup_is_done = False
Exemplo n.º 6
0
    def setup(self, win):
        win.setWindowTitle("Acconeer envelope example")

        self.plot = win.addPlot()
        self.plot.setMenuEnabled(False)
        self.plot.showGrid(x=True, y=True)
        self.plot.setLabel("bottom", "Depth (m)")
        self.plot.setLabel("left", "Amplitude")

        self.curves = []
        for i, _ in enumerate(self.sensor_config.sensor):
            curve = self.plot.plot(pen=utils.pg_pen_cycler(i))
            self.curves.append(curve)

        self.smooth_max = utils.SmoothMax(self.sensor_config.update_rate)
    def __init__(self, sensor_config, processing_config, session_info):
        self.processing_config = processing_config

        self.downsampling_factor = sensor_config.downsampling_factor
        self.sweeps_per_frame = sensor_config.sweeps_per_frame
        sweep_rate = session_info["sweep_rate"]
        self.depths = utils.get_range_depths(sensor_config, session_info)
        self.step_length = session_info["step_length_m"]
        self.f_res = sweep_rate / self.sweeps_per_frame
        self.fft_x_scale = 100 * self.step_length

        self.smooth_max = utils.SmoothMax(
            sweep_rate / self.sweeps_per_frame,
            tau_grow=0,
            tau_decay=0.5,
            hysteresis=0.1,
        )

        self.setup_is_done = False
Exemplo n.º 8
0
    def setup(self, win):
        win.setWindowTitle("Acconeer power bins example")

        self.plot = win.addPlot()
        self.plot.setMenuEnabled(False)
        self.plot.showGrid(x=True, y=True)
        self.plot.setLabel("bottom", "Depth (m)")
        self.plot.setLabel("left", "Amplitude")

        self.curves = []
        for i, _ in enumerate(self.sensor_config.sensor):
            curve = self.plot.plot(
                pen=utils.pg_pen_cycler(i),
                symbol="o",
                symbolPen="k",
                symbolBrush=pg.mkBrush(utils.color_cycler(i)),
            )
            self.curves.append(curve)

        self.smooth_max = utils.SmoothMax(self.sensor_config.update_rate)
    def setup(self, win):
        win.setWindowTitle("Acconeer presence detection example")

        self.limit_lines = []
        dashed_pen = pg.mkPen("k", width=2.5, style=QtCore.Qt.DashLine)

        # Data plot

        self.data_plot = win.addPlot(
            row=0,
            col=0,
            title="Frame (blue), fast (orange), and slow (green)",
        )
        self.data_plot.setMenuEnabled(False)
        self.data_plot.setMouseEnabled(x=False, y=False)
        self.data_plot.hideButtons()
        self.data_plot.showGrid(x=True, y=True)
        self.data_plot.setLabel("bottom", "Depth (m)")
        self.data_plot.setLabel("left", "Amplitude")
        self.data_plot.setYRange(0, 2**16)
        self.frame_scatter = pg.ScatterPlotItem(
            size=10,
            brush=utils.pg_brush_cycler(0),
        )
        self.fast_scatter = pg.ScatterPlotItem(
            size=10,
            brush=utils.pg_brush_cycler(1),
        )
        self.slow_scatter = pg.ScatterPlotItem(
            size=10,
            brush=utils.pg_brush_cycler(2),
        )
        self.data_plot.addItem(self.frame_scatter)
        self.data_plot.addItem(self.fast_scatter)
        self.data_plot.addItem(self.slow_scatter)
        self.frame_smooth_limits = utils.SmoothLimits(
            self.sensor_config.update_rate)

        # Noise estimation plot

        self.noise_plot = win.addPlot(
            row=1,
            col=0,
            title="Noise",
        )
        self.noise_plot.setMenuEnabled(False)
        self.noise_plot.setMouseEnabled(x=False, y=False)
        self.noise_plot.hideButtons()
        self.noise_plot.showGrid(x=True, y=True)
        self.noise_plot.setLabel("bottom", "Depth (m)")
        self.noise_plot.setLabel("left", "Amplitude")
        self.noise_curve = self.noise_plot.plot(pen=utils.pg_pen_cycler())
        self.noise_smooth_max = utils.SmoothMax(self.sensor_config.update_rate)

        # Depthwise presence plot

        self.move_plot = win.addPlot(
            row=2,
            col=0,
            title="Depthwise presence",
        )
        self.move_plot.setMenuEnabled(False)
        self.move_plot.setMouseEnabled(x=False, y=False)
        self.move_plot.hideButtons()
        self.move_plot.showGrid(x=True, y=True)
        self.move_plot.setLabel("bottom", "Depth (m)")
        self.move_plot.setLabel("left", "Norm. ampl.")
        zero_curve = self.move_plot.plot(self.depths,
                                         np.zeros_like(self.depths))
        self.inter_curve = self.move_plot.plot()
        self.total_curve = self.move_plot.plot()
        self.move_smooth_max = utils.SmoothMax(
            self.sensor_config.update_rate,
            tau_decay=1.0,
            tau_grow=0.25,
        )

        self.move_depth_line = pg.InfiniteLine(pen=pg.mkPen("k", width=1.5))
        self.move_depth_line.hide()
        self.move_plot.addItem(self.move_depth_line)
        limit_line = pg.InfiniteLine(angle=0, pen=dashed_pen)
        self.move_plot.addItem(limit_line)
        self.limit_lines.append(limit_line)

        fbi = pg.FillBetweenItem(
            zero_curve,
            self.inter_curve,
            brush=utils.pg_brush_cycler(0),
        )
        self.move_plot.addItem(fbi)

        fbi = pg.FillBetweenItem(
            self.inter_curve,
            self.total_curve,
            brush=utils.pg_brush_cycler(1),
        )
        self.move_plot.addItem(fbi)

        # Presence history plot

        self.move_hist_plot = pg.PlotItem(title="Presence history")
        self.move_hist_plot.setMenuEnabled(False)
        self.move_hist_plot.setMouseEnabled(x=False, y=False)
        self.move_hist_plot.hideButtons()
        self.move_hist_plot.showGrid(x=True, y=True)
        self.move_hist_plot.setLabel("bottom", "Time (s)")
        self.move_hist_plot.setLabel(
            "left", "Score (limited to {})".format(OUTPUT_MAX))
        self.move_hist_plot.setXRange(-self.history_length_s, 0)
        self.move_hist_plot.setYRange(0, OUTPUT_MAX)
        self.move_hist_curve = self.move_hist_plot.plot(
            pen=utils.pg_pen_cycler())
        limit_line = pg.InfiniteLine(angle=0, pen=dashed_pen)
        self.move_hist_plot.addItem(limit_line)
        self.limit_lines.append(limit_line)

        self.present_html_format = '<div style="text-align: center">' \
                                   '<span style="color: #FFFFFF;font-size:15pt;">' \
                                   "{}</span></div>"
        not_present_html = '<div style="text-align: center">' \
                           '<span style="color: #FFFFFF;font-size:15pt;">' \
                           "{}</span></div>".format("No presence detected")
        self.present_text_item = pg.TextItem(
            fill=pg.mkColor(0xff, 0x7f, 0x0e, 200),
            anchor=(0.5, 0),
        )
        self.not_present_text_item = pg.TextItem(
            html=not_present_html,
            fill=pg.mkColor(0x1f, 0x77, 0xb4, 180),
            anchor=(0.5, 0),
        )

        pos = (-self.history_length_s / 2, 0.95 * OUTPUT_MAX)
        self.present_text_item.setPos(*pos)
        self.not_present_text_item.setPos(*pos)
        self.move_hist_plot.addItem(self.present_text_item)
        self.move_hist_plot.addItem(self.not_present_text_item)
        self.present_text_item.hide()

        # Sector plot

        self.sector_plot = pg.PlotItem()
        self.sector_plot.setAspectLocked()
        self.sector_plot.hideAxis("left")
        self.sector_plot.hideAxis("bottom")
        self.sectors = []

        pen = pg.mkPen("k", width=1)
        span_deg = 25
        for r in np.flip(np.arange(self.num_sectors) + 1):
            sector = pg.QtGui.QGraphicsEllipseItem(-r, -r, r * 2, r * 2)
            sector.setStartAngle(-16 * span_deg)
            sector.setSpanAngle(16 * span_deg * 2)
            sector.setPen(pen)
            self.sector_plot.addItem(sector)
            self.sectors.append(sector)

        self.sectors.reverse()

        sublayout = win.addLayout(row=3, col=0)
        sublayout.layout.setColumnStretchFactor(0, 2)
        sublayout.addItem(self.move_hist_plot, col=0)
        sublayout.addItem(self.sector_plot, col=1)

        self.setup_is_done = True
        self.update_processing_config()
Exemplo n.º 10
0
    def setup(self, win):
        win.setWindowTitle("Acconeer Button Press Example")

        self.limit_lines = []
        dashed_pen = pg.mkPen("k", width=2.5, style=QtCore.Qt.DashLine)

        self.sign_hist_plot = win.addPlot(title="Signal history")
        self.sign_hist_plot.setMenuEnabled(False)
        self.sign_hist_plot.addLegend()
        self.sign_hist_plot.showGrid(x=True, y=True)
        self.sign_hist_plot.setLabel("bottom", "Time (s)")
        self.sign_hist_plot.setXRange(-HISTORY_LENGTH_S, 0)
        self.sign_hist_plot.setYRange(0, OUTPUT_MAX_SIGNAL)
        self.sign_hist_curve = self.sign_hist_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Envelope signal",
        )
        self.sign_lp_hist_curve = self.sign_hist_plot.plot(
            pen=utils.pg_pen_cycler(1),
            name="Filtered envelope signal",
        )

        win.nextRow()

        self.rel_dev_hist_plot = win.addPlot(title="Relative deviation history")
        self.rel_dev_hist_plot.setMenuEnabled(False)
        self.rel_dev_hist_plot.showGrid(x=True, y=True)
        self.rel_dev_hist_plot.setLabel("bottom", "Time (s)")
        self.rel_dev_hist_plot.setXRange(-HISTORY_LENGTH_S, 0)
        self.rel_dev_hist_plot.setYRange(0, OUTPUT_MAX_REL_DEV)
        self.rel_dev_lp_hist_curve = self.rel_dev_hist_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Relative deviation",
        )

        self.detection_dots = self.rel_dev_hist_plot.plot(
            pen=None,
            symbol='o',
            symbolSize=20,
            symbolBrush=utils.color_cycler(1),
            name="Detections",
        )
        self.rel_dev_hist_plot.addItem(self.detection_dots)

        limit_line = pg.InfiniteLine(angle=0, pen=dashed_pen)
        self.rel_dev_hist_plot.addItem(limit_line)

        self.limit_lines.append(limit_line)

        self.detection_html_format = '<div style="text-align: center">' \
                                     '<span style="color: #FFFFFF;font-size:16pt;">' \
                                     '{}</span></div>'
        detection_html = self.detection_html_format.format("Button press detected!")

        self.detection_text_item = pg.TextItem(
            html=detection_html,
            fill=pg.mkColor(255, 140, 0),
            anchor=(0.5, 0),
        )

        self.detection_text_item.setPos(-HISTORY_LENGTH_S / 2, 0.95 * OUTPUT_MAX_REL_DEV)
        self.rel_dev_hist_plot.addItem(self.detection_text_item)
        self.detection_text_item.hide()

        self.smooth_max_signal = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=3,
        )

        self.smooth_max_rel_dev = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=3,
        )

        self.setup_is_done = True
        self.update_processing_config()
    def setup(self, win):
        win.setWindowTitle("Acconeer Parking Detector")

        # Sweep Plot
        self.sweep_plot = win.addPlot(title="Sweep")
        self.sweep_plot.setMenuEnabled(False)
        self.sweep_plot.setMouseEnabled(x=False, y=False)
        self.sweep_plot.hideButtons()
        self.sweep_plot.showGrid(x=True, y=True)
        self.sweep_plot.addLegend(offset=(-10, 10))
        self.sweep_plot.setLabel("bottom", "Distance (cm)")
        self.sweep_plot.setLabel("left", "Amplitude")
        self.sweep_plot.setYRange(0, 2000)
        self.sweep_plot.setXRange(100.0 * self.depths[0],
                                  100.0 * self.depths[-1])

        self.sweep_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Envelope sweep",
        )

        self.sweep_background = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(2),
            name="Background estimate",
        )

        self.leak_estimate = self.sweep_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=8,
            symbolPen="k",
            symbolBrush=utils.color_cycler(1),
            name="Leak estimate",
        )

        # To show the legend correctly before the first update
        self.leak_estimate.setData([], [])

        self.smooth_max_sweep = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=5,
        )

        win.nextRow()

        # Reflector weight Plot
        self.weight_plot = win.addPlot(title="Reflection observables")
        self.weight_plot.setMenuEnabled(False)
        self.weight_plot.setMouseEnabled(x=False, y=False)
        self.weight_plot.hideButtons()
        self.weight_plot.showGrid(x=True, y=True)
        self.weight_plot.addLegend(offset=(-10, 10))
        self.weight_plot.setLabel("bottom", "Distance (cm)")
        self.weight_plot.setLabel("left", "Weight")
        self.weight_plot.setYRange(0, 500)
        self.weight_plot.setXRange(100.0 * self.depths[0],
                                   100.0 * self.depths[-1])

        self.detection_html_format = '<div style="text-align: center">' \
                                     '<span style="color: #FFFFFF;font-size:16pt;">' \
                                     '{}</span></div>'
        detection_html = self.detection_html_format.format(
            "Parked car detected!")

        self.detection_text_item = pg.TextItem(
            html=detection_html,
            fill=pg.mkColor(255, 140, 0),
            anchor=(0.5, 0),
        )

        self.weight_plot.addItem(self.detection_text_item)
        self.detection_text_item.hide()

        self.weight_curve = self.weight_plot.plot(
            pen=utils.pg_pen_cycler(0),
            name="Reflector weight",
        )

        self.limits_center = None
        self.detection_limits = self.weight_plot.plot(
            pen=utils.pg_pen_cycler(3),
            name="Detection limits",
        )
        self.limit_line = pg.InfiniteLine(angle=0,
                                          pen=utils.pg_pen_cycler(3, "--"))
        self.weight_plot.addItem(self.limit_line)

        self.trailing_sweeps = self.weight_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=8,
            symbolPen="k",
            symbolBrush=utils.color_cycler(2),
            name="Queued sweep",
        )

        self.current_sweep = self.weight_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=8,
            symbolPen="k",
            symbolBrush=utils.color_cycler(1),
            name="Last sweep",
        )

        # To show the legends correctly before the first update
        self.trailing_sweeps.setData([], [])
        self.current_sweep.setData([], [])

        self.smooth_max_weight = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=5,
        )

        win.nextRow()

        # Detection history Plot
        self.hist_plot = win.addPlot(title="Detection history")
        self.hist_plot.setMenuEnabled(False)
        self.hist_plot.setMouseEnabled(x=False, y=False)
        self.hist_plot.hideButtons()
        self.hist_plot.showGrid(x=True, y=False)
        self.hist_plot.hideAxis("left")
        self.hist_plot.setLabel("bottom", "Time (s)")
        self.hist_plot.setYRange(-0.5, 1.5)
        self.true_text_item = pg.TextItem("True",
                                          color=pg.mkColor(0, 0, 0),
                                          anchor=(0, 0.5))
        self.true_text_item.setPos(
            0.01 * self.processing_config.history_length_s, 1)
        self.false_text_item = pg.TextItem("False",
                                           color=pg.mkColor(0, 0, 0),
                                           anchor=(0, 0.5))
        self.false_text_item.setPos(
            0.01 * self.processing_config.history_length_s, 0)
        self.hist_plot.addItem(self.true_text_item)
        self.hist_plot.addItem(self.false_text_item)

        self.hist_dots = self.hist_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=5,
            symbolPen="k",
            symbolBrush=utils.color_cycler(0),
        )

        win.layout.setRowStretchFactor(0, 8)
        win.layout.setRowStretchFactor(1, 9)

        self.update_processing_config()
Exemplo n.º 12
0
 def __init__(self, sensor_config, processing_config, session_info):
     self.session_info = session_info
     self.smooth_max = utils.SmoothMax(sensor_config.update_rate)
    def setup(self, win):
        # Data plots

        self.data_plots = []
        self.data_curves = []
        for i in range(self.num_depths):
            title = "{:.0f} cm".format(100 * self.depths[i])
            plot = win.addPlot(row=0, col=i, title=title)
            plot.setMenuEnabled(False)
            plot.showGrid(x=True, y=True)
            plot.setYRange(0, 2**16)
            plot.hideAxis("left")
            plot.hideAxis("bottom")
            plot.plot(np.arange(self.sweeps_per_frame),
                      2**15 * np.ones(self.sweeps_per_frame))
            curve = plot.plot(pen=utils.pg_pen_cycler())
            self.data_plots.append(plot)
            self.data_curves.append(curve)

        # Spectral density plot

        self.sd_plot = win.addPlot(row=1, col=0, colspan=self.num_depths)
        self.sd_plot.setMenuEnabled(False)
        self.sd_plot.setLabel("left", "Normalized PSD (dB)")
        self.sd_plot.showGrid(x=True, y=True)
        self.sd_curve = self.sd_plot.plot(pen=utils.pg_pen_cycler())
        dashed_pen = pg.mkPen("k", width=2, style=QtCore.Qt.DashLine)
        self.sd_threshold_line = pg.InfiniteLine(angle=0, pen=dashed_pen)
        self.sd_plot.addItem(self.sd_threshold_line)

        self.smooth_max = utils.SmoothMax(
            self.est_update_rate,
            tau_decay=0.5,
            tau_grow=0,
            hysteresis=0.2,
        )

        # Rolling speed plot

        self.vel_plot = pg.PlotItem()
        self.vel_plot.setMenuEnabled(False)
        self.vel_plot.setLabel("bottom", "Time (s)")
        self.vel_plot.showGrid(x=True, y=True)
        self.vel_plot.setXRange(-EST_VEL_HISTORY_LENGTH, 0)
        self.vel_max_line = pg.InfiniteLine(angle=0,
                                            pen=pg.mkPen("k", width=1))
        self.vel_plot.addItem(self.vel_max_line)
        self.vel_scatter = pg.ScatterPlotItem(size=8)
        self.vel_plot.addItem(self.vel_scatter)

        self.vel_html_fmt = '<span style="color:#000;font-size:24pt;">{:.1f} {}</span>'
        self.vel_text_item = pg.TextItem(anchor=(0.5, 0))
        self.vel_plot.addItem(self.vel_text_item)

        # Sequence speed plot

        self.sequences_plot = pg.PlotItem()
        self.sequences_plot.setMenuEnabled(False)
        self.sequences_plot.setLabel("bottom", "History")
        self.sequences_plot.showGrid(y=True)
        self.sequences_plot.setXRange(-NUM_SAVED_SEQUENCES + 0.5, 0.5)
        tmp = np.flip(np.arange(NUM_SAVED_SEQUENCES) == 0)
        brushes = [pg.mkBrush(utils.color_cycler(n)) for n in tmp]
        self.bar_graph = pg.BarGraphItem(
            x=np.arange(-NUM_SAVED_SEQUENCES, 0) + 1,
            height=np.zeros(NUM_SAVED_SEQUENCES),
            width=0.8,
            brushes=brushes,
        )
        self.sequences_plot.addItem(self.bar_graph)

        self.sequences_text_item = pg.TextItem(anchor=(0.5, 0))
        self.sequences_plot.addItem(self.sequences_text_item)

        sublayout = win.addLayout(row=2, col=0, colspan=self.num_depths)
        sublayout.addItem(self.vel_plot, col=0)
        sublayout.addItem(self.sequences_plot, col=1)

        self.setup_is_done = True
        self.update_processing_config()
Exemplo n.º 14
0
 def __init__(self, sensor_config, processing_config, session_info):
     self.depths = utils.get_range_depths(sensor_config, session_info)
     self.smooth_max = utils.SmoothMax(sensor_config.update_rate)
Exemplo n.º 15
0
    def setup(self, win):
        win.setWindowTitle("Acconeer Distance Detector")

        # Sweep Plot
        self.sweep_plot = win.addPlot(title="Sweep and threshold")
        self.sweep_plot.showGrid(x=True, y=True)
        self.sweep_plot.addLegend()
        self.sweep_plot.setLabel("bottom", "Distance (cm)")
        self.sweep_plot.setYRange(0, 20000)
        self.sweep_plot.setXRange(100.0 * self.r[0], 100.0 * self.r[-1])

        self.sweep_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(5),
            name="Envelope sweep",
        )

        self.mean_sweep_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(0, width=3),
            name="Mean Envelope sweep",
        )

        self.threshold_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(1),
            name="Threshold",
        )

        self.smooth_max_sweep = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=3,
        )

        win.nextRow()

        # Detection history Plot
        self.hist_plot = win.addPlot(title="Detected peaks")
        self.hist_plot.showGrid(x=True, y=True)
        self.hist_plot.addLegend()
        self.hist_plot.setLabel("bottom", "Time history (s)")
        self.hist_plot.setLabel("left", "Distance (cm)")
        self.hist_plot.setXRange(-10, 0)
        self.hist_plot.setYRange(100.0 * self.r[0], 100.0 * self.r[-1])

        self.main_peak = self.hist_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=8,
            symbolPen='k',
            symbolBrush=utils.color_cycler(0),
            name="Main peak",
        )

        self.minor_peaks = self.hist_plot.plot(
            pen=None,
            symbol='o',
            symbolSize=5,
            symbolPen='k',
            symbolBrush=utils.color_cycler(1),
            name="Minor peaks",
        )

        self.setup_is_done = True
    def setup(self, win):
        win.setWindowTitle("Acconeer Distance Detector")

        # Sweep Plot
        self.sweep_plot = win.addPlot(title="Sweep and threshold")
        self.sweep_plot.setMenuEnabled(False)
        self.sweep_plot.setMouseEnabled(x=False, y=False)
        self.sweep_plot.hideButtons()
        self.sweep_plot.showGrid(x=True, y=True)
        self.sweep_plot.addLegend()
        self.sweep_plot.setLabel("bottom", "Distance (cm)")
        self.sweep_plot.setYRange(0, 20000)
        self.sweep_plot.setXRange(100.0 * self.r[0], 100.0 * self.r[-1])

        self.sweep_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(5),
            name="Envelope sweep",
        )

        self.mean_sweep_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(0, width=3),
            name="Mean Envelope sweep",
        )

        self.threshold_curve = self.sweep_plot.plot(
            pen=utils.pg_pen_cycler(1),
            name="Threshold",
        )

        self.smooth_max_sweep = utils.SmoothMax(
            self.sensor_config.update_rate,
            hysteresis=0.6,
            tau_decay=3,
        )

        self.peak_lines = []
        for i in range(3):
            color_idx = 1 if i > 0 else 0
            width = 2 if i == 0 else 1
            color_tuple = utils.hex_to_rgb_tuple(utils.color_cycler(color_idx))
            line = pg.InfiniteLine(
                pen=pg.mkPen(pg.mkColor(*color_tuple, 150), width=width))
            self.sweep_plot.addItem(line)
            self.peak_lines.append(line)

        self.peak_text = pg.TextItem(
            anchor=(0, 1),
            color=utils.color_cycler(0),
            fill=pg.mkColor(0xFF, 0xFF, 0xFF, 150),
        )
        self.peak_text.setPos(self.r[0] * 100, 0)
        self.peak_text.setZValue(100)
        self.sweep_plot.addItem(self.peak_text)

        win.nextRow()

        # Detection history Plot
        self.hist_plot = win.addPlot(title="Detected peaks")
        self.hist_plot.setMenuEnabled(False)
        self.hist_plot.setMouseEnabled(x=False, y=False)
        self.hist_plot.hideButtons()
        self.hist_plot.showGrid(x=True, y=True)
        self.hist_plot.addLegend()
        self.hist_plot.setLabel("bottom", "Time history (s)")
        self.hist_plot.setLabel("left", "Distance (cm)")
        self.hist_plot.setXRange(-10, 0)
        self.hist_plot.setYRange(100.0 * self.r[0], 100.0 * self.r[-1])

        self.main_peak = self.hist_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=8,
            symbolPen="k",
            symbolBrush=utils.color_cycler(0),
            name="Main peak",
        )

        self.minor_peaks = self.hist_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=5,
            symbolPen="k",
            symbolBrush=utils.color_cycler(1),
            name="Minor peaks",
        )

        self.first_distance_above_threshold = self.hist_plot.plot(
            pen=None,
            symbol="o",
            symbolSize=3,
            symbolPen="k",
            symbolBrush=utils.color_cycler(2),
            name="First distance above threshold",
            visible=False,
        )

        self.setup_is_done = True
Exemplo n.º 17
0
def main():
    args = utils.ExampleArgumentParser(num_sens=1).parse_args()
    utils.config_logging(args)

    if args.socket_addr:
        client = SocketClient(args.socket_addr)
    elif args.spi:
        client = SPIClient()
    else:
        port = args.serial_port or utils.autodetect_serial_port()
        client = UARTClient(port)

    config = configs.EnvelopeServiceConfig()
    config.sensor = args.sensors
    config.update_rate = 30

    session_info = client.setup_session(config)

    start = session_info["range_start_m"]
    length = session_info["range_length_m"]
    num_depths = session_info["data_length"]
    step_length = session_info["step_length_m"]
    depths = np.linspace(start, start + length, num_depths)
    num_hist = 2 * int(round(config.update_rate))
    hist_data = np.zeros([num_hist, depths.size])
    smooth_max = utils.SmoothMax(config.update_rate)

    app = QtWidgets.QApplication([])
    pg.setConfigOption("background", "w")
    pg.setConfigOption("foreground", "k")
    pg.setConfigOptions(antialias=True)
    win = pg.GraphicsLayoutWidget()
    win.setWindowTitle("Acconeer PyQtGraph example")

    env_plot = win.addPlot(title="Envelope")
    env_plot.showGrid(x=True, y=True)
    env_plot.setLabel("bottom", "Depth (m)")
    env_plot.setLabel("left", "Amplitude")
    env_curve = env_plot.plot(pen=pg.mkPen("k", width=2))

    win.nextRow()
    hist_plot = win.addPlot()
    hist_plot.setLabel("bottom", "Time (s)")
    hist_plot.setLabel("left", "Depth (m)")
    hist_image_item = pg.ImageItem()
    hist_image_item.translate(-2, start)
    hist_image_item.scale(2 / num_hist, step_length)
    hist_plot.addItem(hist_image_item)

    # Get a nice colormap from matplotlib
    hist_image_item.setLookupTable(utils.pg_mpl_cmap("viridis"))

    win.show()

    interrupt_handler = utils.ExampleInterruptHandler()
    win.closeEvent = lambda _: interrupt_handler.force_signal_interrupt()
    print("Press Ctrl-C to end session")

    client.start_session()

    while not interrupt_handler.got_signal:
        info, data = client.get_next()

        hist_data = np.roll(hist_data, -1, axis=0)
        hist_data[-1] = data

        env_curve.setData(depths, data)
        env_plot.setYRange(0, smooth_max.update(data))
        hist_image_item.updateImage(hist_data,
                                    levels=(0, np.max(hist_data) * 1.05))

        app.processEvents()

    print("Disconnecting...")
    app.closeAllWindows()
    client.disconnect()