def get_base_config():
    config = configs.EnvelopeServiceConfig()
    config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    config.range_interval = [0.3, 0.8]
    config.sweep_rate = 50
    config.gain = 0.7
    return config
Example #2
0
def get_sensor_config():
    config = configs.EnvelopeServiceConfig()
    config.session_profile = configs.EnvelopeServiceConfig.DIRECT_LEAKAGE
    config.range_interval = [0.04, 0.05]
    config.running_average_factor = 0.01
    config.sweep_rate = 60
    config.gain = 0.2
    return config
Example #3
0
def config_setup():
    config = configs.EnvelopeServiceConfig()
    # config = configs.IQServiceConfig()
    config.range_interval = [0.4, 0.8]
    config.sweep_rate = 10
    config.gain = 1
    config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    return config
Example #4
0
def config_setup():
    config = configs.EnvelopeServiceConfig()
    config.range_interval = [0.3, 0.7]
    config.sweep_rate = 2
    config.gain = 1
    config.session_profile = configs.EnvelopeServiceConfig.MAX_DEPTH_RESOLUTION
    #config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    print(config.gain)
    return config
Example #5
0
def test_envelope(setup):
    client, sensor = setup

    config = configs.EnvelopeServiceConfig(sensor=sensor)
    session_info = client.start_streaming(config)
    _, sweep = client.get_next()
    client.stop_streaming()

    assert sweep.shape == (session_info["data_length"], )
Example #6
0
    def __init__(self, demo_ctrl, params):
        super().__init__(demo_ctrl, self.detector_name)

        self.config = configs.EnvelopeServiceConfig()

        self.update_config(params)

        if "profile" in params:
            if params["profile"] == "0":
                self.config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
            elif params["profile"] == "1":
                self.config.session_profile = configs.EnvelopeServiceConfig.MAX_DEPTH_RESOLUTION
            else:
                print("Unknown profile")
Example #7
0
def main():
    args = example_utils.ExampleArgumentParser().parse_args()
    example_utils.config_logging(args)

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

    client.squeeze = False

    config = configs.EnvelopeServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.3, 0.8]
    config.sweep_rate = 70
    config.gain = 0.6
    # config.experimental_stitching = True
    # config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    # config.running_average_factor = 0.5
    # config.compensate_phase = False  # not recommended

    info = client.setup_session(config)
    num_points = info["data_length"]

    pg_updater = PGUpdater(config, num_points)
    pg_process = PGProcess(pg_updater)
    pg_process.start()

    client.start_streaming()

    interrupt_handler = example_utils.ExampleInterruptHandler()
    print("Press Ctrl-C to end session")

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

        try:
            pg_process.put_data(data)
            print(data)
            input("Enter")
        except PGProccessDiedException:
            break

    print("Disconnecting...")
    pg_process.close()
    client.disconnect()
Example #8
0
    def init_dropdowns(self):
        self.mode = QComboBox(self)
        self.mode.addItem("Select service")
        self.mode.addItem("IQ")
        self.mode.addItem("Envelope")
        self.mode.addItem("Power bin")
        self.mode.addItem("Phase tracking")
        self.mode.addItem("Presence detection")
        self.mode.addItem("Breathing")
        self.mode.addItem("Sleep breathing")
        self.mode.addItem("Obstacle detection")
        self.mode.move(50, 250)

        self.mode_to_param = {
            "Select service": "",
            "IQ": "iq_data",
            "Envelope": "envelope_data",
            "Power bin": "power_bin",
            "Breathing": "iq_data",
            "Phase tracking": "iq_data",
            "Presence detection": "iq_data",
            "Sleep breathing": "iq_data",
            "Obstacle detection": "iq_data",
        }

        self.mode_to_config = {
            "Select service": ["", ""],
            "IQ": [configs.IQServiceConfig(), "internal"],
            "Envelope": [configs.EnvelopeServiceConfig(), "internal"],
            "Power bin": [configs.PowerBinServiceConfig(), "internal_power"],
            "Breathing": [br.get_base_config(), "external"],
            "Phase tracking": [pht.get_base_config(), "external"],
            "Presence detection": [prd.get_base_config(), "external"],
            "Sleep breathing": [sb.get_base_config(), "external"],
            "Obstacle detection": [od.get_base_config(), "external"]
        }

        self.mode.currentIndexChanged.connect(self.update_canvas)

        self.interface = QComboBox(self)
        self.interface.addItem("Socket")
        self.interface.addItem("Serial")
        self.interface.currentIndexChanged.connect(self.update_interface)

        self.ports = QComboBox(self)
        self.ports.addItem("Scan ports")
        self.ports.activated.connect(self.update_ports)
        self.update_ports()
def main():
    args = example_utils.ExampleArgumentParser().parse_args()
    example_utils.config_logging(args)

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

    # Normally when using a single sensor, get_next will return
    # (info, data). When using mulitple sensors, get_next will return
    # lists of info and data for each sensor, i.e. ([info], [data]).
    # This is commonly called squeezing. To disable squeezing, making
    # get_next _always_ return lists, set:
    # client.squeeze = False

    config = configs.EnvelopeServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.3]
    config.sweep_rate = 5

    session_info = client.setup_session(config)
    print("Session info:\n", session_info, "\n")

    # Now would be the time to set up plotting, signal processing, etc.

    client.start_streaming()

    # Normally, hitting Ctrl-C will raise a KeyboardInterrupt which in
    # most cases immediately terminates the script. This often becomes
    # an issue when plotting and also doesn't allow us to disconnect
    # gracefully. Setting up an ExampleInterruptHandler will capture the
    # keyboard interrupt signal so that a KeyboardInterrupt isn't raised
    # and we can take care of the signal ourselves. In case you get
    # impatient, hitting Ctrl-C a couple of more times will raise a
    # KeyboardInterrupt which hopefully terminates the script.
    interrupt_handler = example_utils.ExampleInterruptHandler()
    print("Press Ctrl-C to end session\n")

    while not interrupt_handler.got_signal:
        info, data = client.get_next()
        print(info, "\n", data, "\n")

    print("Disconnecting...")
    client.disconnect()
Example #10
0
def main():
    args = example_utils.ExampleArgumentParser().parse_args()
    example_utils.config_logging(args)

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

    config = configs.EnvelopeServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 10

    client.start_streaming(config)
    client.get_next()
    client.disconnect()
Example #11
0
def main():
    args = example_utils.ExampleArgumentParser().parse_args()
    example_utils.config_logging(args)

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

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

    info = client.connect()
    print("connect info:", info)
    client.start_streaming(config)
    client.get_next()
    client.disconnect()
def get_sensor_config():
    return configs.EnvelopeServiceConfig()
def main():
    args = example_utils.ExampleArgumentParser(num_sens=1).parse_args()
    example_utils.config_logging(args)

    if args.socket_addr:
        client = JSONClient(args.socket_addr)
    else:
        port = args.serial_port or example_utils.autodetect_serial_port()
        client = RegClient(port)

    config = configs.EnvelopeServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 60
    config.gain = 0.65

    info = client.setup_session(config)
    num_points = info["data_length"]
    xs = np.linspace(*config.range_interval, num_points)
    num_hist = 2 * config.sweep_rate

    hist_data = np.zeros([num_hist, num_points])
    hist_max = np.zeros(num_hist)
    smooth_max = example_utils.SmoothMax(config.sweep_rate)

    app = QtGui.QApplication([])
    pg.setConfigOption("background", "w")
    pg.setConfigOption("foreground", "k")
    pg.setConfigOptions(antialias=True)
    win = pg.GraphicsLayoutWidget()
    win.closeEvent = lambda _: interrupt_handler.force_signal_interrupt()
    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, config.range_start)
    hist_image_item.scale(2 / num_hist, config.range_length / num_points)
    hist_plot.addItem(hist_image_item)

    # try to get a colormap from matplotlib
    try:
        hist_image_item.setLookupTable(example_utils.pg_mpl_cmap("viridis"))
    except ImportError:
        pass

    win.show()

    interrupt_handler = example_utils.ExampleInterruptHandler()
    print("Press Ctrl-C to end session")

    client.start_streaming()

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

        hist_data = np.roll(hist_data, -1, axis=0)
        hist_data[-1] = sweep
        hist_max = np.roll(hist_max, -1)
        hist_max[-1] = np.max(sweep)
        y_max = smooth_max.update(np.amax(hist_max))
        env_curve.setData(xs, sweep)
        env_plot.setYRange(0, y_max)
        hist_image_item.updateImage(hist_data, levels=(0, y_max))

        app.processEvents()

    print("Disconnecting...")
    app.closeAllWindows()
    client.disconnect()
def main():
    # To simplify the examples, we use a generic argument parser. It
    # lets you choose between UART/socket, set which sensor(s) to use,
    # and the verbosity level of the logging.
    args = example_utils.ExampleArgumentParser().parse_args()

    # Logging is done using the logging module with a logger named
    # acconeer_utils. We call another helper function which sets up the
    # logging according to the verbosity level set in the arguments.
    # -q  or --quiet:   ERROR   (typically not used)
    # default:          WARNING
    # -v  or --verbose: INFO
    # -vv or --debug:   DEBUG
    example_utils.config_logging(args)

    # Pick client depending on whether socket, SPI, or UART is used
    if args.socket_addr:
        client = JSONClient(args.socket_addr)
    elif args.spi:
        client = RegSPIClient()
    else:
        port = args.serial_port or example_utils.autodetect_serial_port()
        client = RegClient(port)

    # Create a configuration to run on the sensor. A good first choice
    # is the envelope service, so let's pick that one.
    config = configs.EnvelopeServiceConfig()

    # In all examples, we let you set the sensor(s) via the command line
    config.sensor = args.sensors

    # Set the measurement range [meter]
    config.range_interval = [0.2, 0.3]

    # Set the target measurement rate [Hz]
    config.sweep_rate = 10

    # Other configuration options might be available. Check out the
    # example for the corresponding service/detector to see more.

    client.connect()

    # In most cases, explicitly calling connect is not necessary as
    # setup_session below will call connect if not already connected.

    # Set up the session with the config we created. If all goes well,
    # some information/metadata for the configured session is returned.
    session_info = client.setup_session(config)
    print("Session info:\n", session_info, "\n")

    # Now would be the time to set up plotting, signal processing, etc.

    # Start streaming data from the session. This call will block until
    # the sensor has confirmed that streaming has started.
    client.start_streaming()

    # Alternatively, start_streaming can be given the config instead. In
    # that case, the client will call setup_session(config) for you
    # before starting the stream. For example:
    # session_info = client.start_streaming(config)
    # As this will call setup_session in the background, this will also
    # connect if not already connected.

    # In this simple example, we just want to get a couple of sweeps.
    # To get a sweep, call get_next. get_next will block until the sweep
    # is recieved. Some information/metadata is returned together with
    # the data.

    for i in range(3):
        sweep_info, sweep_data = client.get_next()
        print("Sweep {}:\n".format(i + 1), sweep_info, "\n", sweep_data, "\n")

    # We're done, stop streaming. All buffered/waiting sweeps are thrown
    # away. This call will block until the sensor has confirmed that
    # streaming/session has ended.
    client.stop_streaming()

    # Calling stop_streaming before disconnect is not necessary as
    # disconnect will call stop_streaming if streaming is started.

    # Remember to always call disconnect to do so gracefully
    client.disconnect()
def config_setup():
    config = configs.EnvelopeServiceConfig()
    config.range_interval = [0.4, 0.8]
    config.sweep_rate = 2
    config.gain = 1
    return config