def setup(self, win): num_depths = self.session_info["bin_count"] start = self.session_info["range_start_m"] length = self.session_info["range_length_m"] end = start + length xs = np.linspace(start, end, num_depths * 2 + 1)[1::2] bin_width = 0.8 * length / num_depths 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.plot.setXRange(start, end) self.plot.setYRange(0, 1) self.bar_graph = pg.BarGraphItem( x=xs, height=np.zeros_like(xs), width=bin_width, brush=pg.mkBrush(utils.color_cycler()), ) self.plot.addItem(self.bar_graph)
def setup(self, win): win.resize(800, 600) win.setWindowTitle("Acconeer phase tracking example") self.abs_plot = win.addPlot(row=0, col=0) self.abs_plot.setMenuEnabled(False) self.abs_plot.showGrid(x=True, y=True) self.abs_plot.setLabel("left", "Amplitude") self.abs_plot.setLabel("bottom", "Depth (m)") self.abs_curve = self.abs_plot.plot(pen=utils.pg_pen_cycler(0)) pen = utils.pg_pen_cycler(1) pen.setStyle(QtCore.Qt.DashLine) self.abs_inf_line = pg.InfiniteLine(pen=pen) self.abs_plot.addItem(self.abs_inf_line) self.arg_plot = win.addPlot(row=1, col=0) self.arg_plot.setMenuEnabled(False) self.arg_plot.showGrid(x=True, y=True) self.arg_plot.setLabel("bottom", "Depth (m)") self.arg_plot.setLabel("left", "Phase") self.arg_plot.setYRange(-np.pi, np.pi) self.arg_plot.getAxis("left").setTicks(utils.pg_phase_ticks) self.arg_curve = self.arg_plot.plot(pen=utils.pg_pen_cycler()) self.arg_inf_line = pg.InfiniteLine(pen=pen) self.arg_plot.addItem(self.arg_inf_line) self.iq_plot = win.addPlot(row=1, col=1, title="IQ at line") self.iq_plot.setMenuEnabled(False) utils.pg_setup_polar_plot(self.iq_plot, 1) self.iq_curve = self.iq_plot.plot(pen=utils.pg_pen_cycler()) self.iq_scatter = pg.ScatterPlotItem(brush=pg.mkBrush( utils.color_cycler()), size=15) self.iq_plot.addItem(self.iq_scatter) self.hist_plot = win.addPlot(row=0, col=1, colspan=2) self.hist_plot.setMenuEnabled(False) self.hist_plot.showGrid(x=True, y=True) self.hist_plot.setLabel("bottom", "Time (s)") self.hist_plot.setLabel("left", "Tracking (mm)") self.hist_curve = self.hist_plot.plot(pen=utils.pg_pen_cycler()) self.hist_plot.setYRange(-5, 5) self.hist_zoom_plot = win.addPlot(row=1, col=2) self.hist_zoom_plot.setMenuEnabled(False) self.hist_zoom_plot.showGrid(x=True, y=True) self.hist_zoom_plot.setLabel("bottom", "Time (s)") self.hist_zoom_plot.setLabel("left", "Tracking (mm)") self.hist_zoom_curve = self.hist_zoom_plot.plot( pen=utils.pg_pen_cycler()) self.hist_zoom_plot.setYRange(-0.5, 0.5) self.first = True
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 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
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): num_sensors = len(self.sensor_config.sensor) self.ampl_plot = win.addPlot(row=0, colspan=num_sensors) self.ampl_plot.setMenuEnabled(False) self.ampl_plot.setMouseEnabled(x=False, y=False) self.ampl_plot.hideButtons() self.ampl_plot.showGrid(x=True, y=True) self.ampl_plot.setLabel("bottom", "Depth (m)") self.ampl_plot.setLabel("left", "Amplitude") self.ampl_plot.setXRange(*self.depths.take((0, -1))) self.ampl_plot.setYRange(0, 1) # To avoid rendering bug self.ampl_plot.addLegend(offset=(-10, 10)) self.ampl_curves = [] self.bg_curves = [] self.peak_lines = [] for i, sensor_id in enumerate(self.sensor_config.sensor): legend = "Sensor {}".format(sensor_id) ampl_curve = self.ampl_plot.plot(pen=utils.pg_pen_cycler(i), name=legend) bg_curve = self.ampl_plot.plot(pen=utils.pg_pen_cycler(i, style="--")) color_tuple = utils.hex_to_rgb_tuple(utils.color_cycler(i)) peak_line = pg.InfiniteLine(pen=pg.mkPen(pg.mkColor(*color_tuple, 150), width=2)) self.ampl_plot.addItem(peak_line) self.ampl_curves.append(ampl_curve) self.bg_curves.append(bg_curve) self.peak_lines.append(peak_line) bg = pg.mkColor(0xFF, 0xFF, 0xFF, 150) self.peak_text = pg.TextItem(anchor=(0, 1), color="k", fill=bg) self.peak_text.setPos(self.depths[0], 0) self.peak_text.setZValue(100) self.ampl_plot.addItem(self.peak_text) rate = self.sensor_config.update_rate xlabel = "Sweeps" if rate is None else "Time (s)" x_scale = 1.0 if rate is None else 1.0 / rate y_scale = self.depth_res x_offset = -self.processing_config.history_length * x_scale y_offset = self.depths[0] - 0.5 * self.depth_res is_single_sensor = len(self.sensor_config.sensor) == 1 self.history_plots = [] self.history_ims = [] for i, sensor_id in enumerate(self.sensor_config.sensor): title = None if is_single_sensor else "Sensor {}".format(sensor_id) plot = win.addPlot(row=1, col=i, title=title) plot.setMenuEnabled(False) plot.setMouseEnabled(x=False, y=False) plot.hideButtons() plot.setLabel("bottom", xlabel) plot.setLabel("left", "Depth (m)") im = pg.ImageItem(autoDownsample=True) im.setLookupTable(utils.pg_mpl_cmap("viridis")) im.resetTransform() im.translate(x_offset, y_offset) im.scale(x_scale, y_scale) plot.addItem(im) self.history_plots.append(plot) self.history_ims.append(im) 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()
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): # 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()