def __init__(self, q):
        # Setup radar
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        if self.args.socket_addr:
            self.client = JSONClient(self.args.socket_addr)
        else:
            port = self.args.serial_port or example_utils.autodetect_serial_port()
            self.client = RegClient(port)

        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors
        self.config.range_interval = [0.2, 0.6]  # Intervall för mätningar
        self.config.sweep_rate = 1  # Frekvensen
        self.config.gain = 1  # Gain mellan 0 och 1, vi använder 1
        self.time = 10  # Hur lång mätningen ska vara
        # totalt antal sekvenser som krävs för att få en specifik tid
        self.seq = self.config.sweep_rate * self.time

        self.info = self.client.setup_session(self.config)
        self.num_points = self.info["data_length"]  # Antalet mätpunkter per sekvens
        # print(self.num_points)
        # Matris med nollor som fylls med rardardata
        self.matrix = np.zeros((self.seq, self.num_points), dtype=np.csingle)
        self.matrix_copy = np.zeros((self.seq, self.num_points),
                                    dtype=np.csingle)  # En copy på ovanstående
        self.temp_vector = np.zeros((0, self.num_points), dtype=np.csingle)
        self.matrix_idx = 0  # Index för påfyllning av matris
        super(Radar, self).__init__()
        # En First In First Out (FIFO) kö där mätdata sparas och kan hämtas ut för signalbehandling
        self.q = q
def setup_parameters():
    config = configs.IQServiceConfig()
    config.range_interval = [0.40, 0.70]
    config.sweep_rate = 20
    config.gain = 1
    # config.running_average_factor = 0.5
    return config
Exemplo n.º 3
0
    def __init__(self, radar_queue, interrupt_queue):
        # Setup for collecting data from radar
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        if self.args.socket_addr:
            self.client = JSONClient(self.args.socket_addr)
        else:
            port = self.args.serial_port or example_utils.autodetect_serial_port(
            )
            self.client = RegClient(port)

        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors

        self.config.range_interval = [0.2, 0.6]  # Measurement interval
        self.config.sweep_rate = 1  # Frequency for collecting data
        self.config.gain = 1  # Gain between 0 and 1.
        self.time = 10  # Duration for a set amount of sequences
        self.seq = self.config.sweep_rate * self.time

        self.info = self.client.setup_session(
            self.config)  # Setup acconeer radar session
        self.num_points = self.info[
            "data_length"]  # Amount of data points per sampel

        #### Det här kanske inte ska vara i den här klassen #####
        # Vector for radar values from tracked data
        self.peak_vector = np.zeros((1, self.seq), dtype=np.csingle)
        self.data_idx = 0  # Inedex for peak vector used for filtering

        self.radar_queue = radar_queue
        self.interrupt_queue = interrupt_queue
        self.timeout = time.time() + self.time
        b = 0
Exemplo n.º 4
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.IQServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 50

    info = client.start_streaming(config)

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

    fc = example_utils.FreqCounter(num_bits=(4 * 8 * info["data_length"]))

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

    print("\nDisconnecting...")
    client.disconnect()
Exemplo n.º 5
0
    def __init__(self):
        # Setup radar data
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        if self.args.socket_addr:
            self.client = JSONClient(self.args.socket_addr)
        else:
            port = self.args.serial_port or example_utils.autodetect_serial_port(
            )
            self.client = RegClient(port)

        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors
        self.config.range_interval = [0.2, 0.6]
        self.config.sweep_rate = 1
        self.config.gain = 1
        self.time = 5
        self.seq = self.config.sweep_rate * self.time

        self.info = self.client.setup_session(self.config)
        self.num_points = self.info["data_length"]
        self.matrix = np.zeros((self.seq, self.num_points), dtype=np.csingle)
        self.matrix_copy = np.zeros((self.seq, self.num_points),
                                    dtype=np.csingle)
        self.matrix_idx = 0
        super(Radar, self).__init__()
Exemplo n.º 6
0
def base_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 1
    config.gain = 0.7
    #config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    return config
Exemplo n.º 7
0
def get_base_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.2, 0.5]
    config.sweep_rate = 13
    config.gain = 0.8
    config.running_average_factor = 0.9

    return config
def config_setup():
    config = configs.IQServiceConfig()
    config.range_interval = [0.3, 0.7]
    config.sweep_rate = 100
    config.gain = 1
    #config.session_profile = configs.EnvelopeServiceConfig.MAX_DEPTH_RESOLUTION
    # config.session_profile = configs.EnvelopeServiceConfig.MAX_SNR
    print(config.gain)
    return config
Exemplo n.º 9
0
def main():
    args = example_utils.ExampleArgumentParser().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)

    client.squeeze = False

    config = configs.IQServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [1, 8]
    config.sweep_rate = 1
    config.gain = 0.8
    #config.running_average_factor = 0.5
    tid = 5
    sekvenser = config.sweep_rate * tid

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

    fig_updater = ExampleFigureUpdater(config, num_points)
    plot_process = PlotProcess(fig_updater)
    plot_process.start()

    client.start_streaming()

    interrupt_handler = example_utils.ExampleInterruptHandler()
    print("Press Ctrl-C to end session")
    start = time.time()
    # while not interrupt_handler.got_signal:
    for i in range(0, sekvenser):
        #info, data = client.get_next()
        data = get_data(client)
        plot_data = {
            "amplitude": np.abs(data),
            "phase": np.angle(data),
        }

        try:
            plot_process.put_data(plot_data)
        except PlotProccessDiedException:
            break

    end = time.time()
    # print(i+1)
    print((end - start), "s")
    # print("Disconnecting...")
    plot_process.close()
    client.disconnect()
Exemplo n.º 10
0
    def __init__(self, HR_filter_queue,
                 go):  # Lägg till RR_filter_queue som inputargument
        self.go = go
        # Setup for collecting data from radar
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        if self.args.socket_addr:
            self.client = JSONClient(self.args.socket_addr)
            # Test för att se vilken port som används av radarn
            print("RADAR Port = " + self.args.socket_addr)
        else:
            port = self.args.serial_port or example_utils.autodetect_serial_port(
            )
            self.client = RegClient(port)

        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors

        self.config.range_interval = [0.2, 0.6]  # Measurement interval
        self.config.sweep_rate = 20  # Frequency for collecting data
        self.config.gain = 1  # Gain between 0 and 1.
        self.time = 1  # Duration for a set amount of sequences
        self.seq = self.config.sweep_rate * self.time  # Amount of sequences during a set time and sweep freq

        self.info = self.client.setup_session(
            self.config)  # Setup acconeer radar session
        self.num_points = self.info[
            "data_length"]  # Amount of data points per sampel
        self.data_getting = 0  # Inedex for printing still getting data once a second

        self.HR_filter_queue = HR_filter_queue
        # self.a = a
        # self.RR_filter_queue = RR_filter_queue
        # Initiation for tracking method
        self.N_avg = 10  # How manny peaks averaged over when calculating peaks_filtered
        self.I_peaks = np.zeros(self.N_avg)
        self.locs = np.zeros(self.N_avg)
        self.I_peaks_filtered = np.zeros(self.N_avg)
        self.tracked_distance = np.zeros(self.N_avg)
        self.tracked_amplitude = np.zeros(self.N_avg)
        self.tracked_phase = np.zeros(self.N_avg)
        self.threshold = 0  # variable for finding peaks above threshold
        self.data_idx = 0  # Index in vector for tracking. Puts new tracked peak into tracking vector
        # converts index to real length
        self.real_dist = np.linspace(self.config.range_interval[0],
                                     self.config.range_interval[1],
                                     num=self.num_points)
        self.counter = 0  # Used only for if statement only for first iteration and not when data_idx goes back to zero

        super(Radar, self).__init__()  # Inherit threading vitals
Exemplo n.º 11
0
def test_setup_twice(setup):
    client, sensor = setup

    config = configs.IQServiceConfig(sensor=sensor)

    config.range_length = 0.2
    info_1 = client.setup_session(config)

    config.range_length = 0.3
    info_2 = client.setup_session(config)

    assert abs(0.2 - info_1["actual_range_length"]) < 0.01
    assert abs(0.3 - info_2["actual_range_length"]) < 0.01
    assert info_1["data_length"] < info_2["data_length"]
Exemplo n.º 12
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.IQServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 30
    config.gain = 0.6
    # config.running_average_factor = 0.5

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

    fig_updater = ExampleFigureUpdater(config, num_points)
    plot_process = PlotProcess(fig_updater)
    plot_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()

        plot_data = {
            "amplitude": np.abs(data),
            "phase": np.angle(data),
        }

        try:
            plot_process.put_data(plot_data)
        except PlotProccessDiedException:
            break

    print("Disconnecting...")
    plot_process.close()
    client.disconnect()
Exemplo n.º 13
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()
Exemplo n.º 14
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.IQServiceConfig()
    config.sensor = args.sensors
    config.range_interval = [0.2, 0.6]
    config.sweep_rate = 30
    config.gain = 0.6
    config.sampling_mode = config.SAMPLING_MODE_A
    # config.running_average_factor = 0.5
    # config.hw_accelerated_average_samples = 7
    # config.stepsize = 1

    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)
        except PGProccessDiedException:
            break

    print("Disconnecting...")
    pg_process.close()
    client.disconnect()
Exemplo n.º 15
0
def get_sensor_config():
    return configs.IQServiceConfig()
Exemplo n.º 16
0
def get_sensor_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.3, 0.6]
    config.sweep_rate = 80
    config.gain = 0.7
    return config
Exemplo n.º 17
0
def recordData():
    args = example_utils.ExampleArgumentParser().parse_args()

    example_utils.config_logging(args)

    # Pick client depending on whether socket, SPI, or UART is used
    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.IQServiceConfig()

    config.sensor = args.sensors
    config.range_interval = [0.3, 0.8]
    config.sweep_rate = int(input("Sweep rate (Hz): "))
    config.gain = 0.7

    client.connect()
    session_info = client.setup_session(config)
    dataLength = session_info["data_length"]
    print(dataLength)
    client.start_streaming()

    # Array of sweeps
    data = []
    numSweeps = int(input("Set number of sweeps: "))

    #Control time
    ses_time_start = time()

    #Used for sleep time
    per_time = 1/config.sweep_rate

    # Loop to get data from sensor
    for i in range(numSweeps):
        start_time = time()

        # Get data
        sweep_info, sweep_data = client.get_next()

        # Append to list
        data.append(sweep_data)

        # Sleep time according to frequency
        end_time = time()
        sleep_time = per_time - (end_time - start_time)
        if sleep_time > 0:
            sleep(sleep_time)

    #Control of time
    ses_time = time() - ses_time_start
    print("ses_time: ", ses_time)

    object = input("Object: (W/D) ")
    direction = input("direction (I/O, only for door: ")

    # Save to file
    with open("data" + str(config.sweep_rate) + str(numSweeps) + object + direction + ".pkl", "wb") as outfile:
        pickle.dump(data, outfile, pickle.HIGHEST_PROTOCOL)
    with open("metadata" + str(config.sweep_rate) + str(numSweeps) + object + direction + ".pkl", "wb") as outfile:
        pickle.dump(session_info, outfile, pickle.HIGHEST_PROTOCOL)


    client.stop_streaming()
    client.disconnect()
Exemplo n.º 18
0
    def __init__(self, list_of_variables_for_threads, bluetooth_server):
        super(DataAcquisition, self).__init__()         # Inherit threading vitals

        # Declaration of global variables
        self.go = list_of_variables_for_threads["go"]
        self.list_of_variables_for_threads = list_of_variables_for_threads
        self.bluetooth_server = bluetooth_server
        self.run_measurement = self.list_of_variables_for_threads['run_measurement']
        self.window_slide = self.list_of_variables_for_threads["window_slide"]
        self.initiate_write_respitory_rate = list_of_variables_for_threads["initiate_write_heart_rate"]
        self.resp_rate_csv = []
        # Setup for collecting data from Acconeer's radar files
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        # if self.args.socket_addr:
        #     self.client = JSONClient(self.args.socket_addr)
        #     print("RADAR Port = " + self.args.socket_addr)
        # else:
        #     print("Radar serial port: " + self.args.serial_port)
        #     port = self.args.serial_port or example_utils.autodetect_serial_port()
        #     self.client = RegClient(port)
        self.client = JSONClient('0.0.0.0')
        print("args: " + str(self.args))
        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors
        print(self.args.sensors)
        # self.config.sensor = 1
        # Settings for radar setup
        self.config.range_interval = [0.4, 1.4]  # Measurement interval
        # Frequency for collecting data. To low means that fast movements can't be tracked.
        self.config.sweep_rate = 20  # Probably 40 is the best without graph
        # For use of sample freq in other threads and classes.
        self.list_of_variables_for_threads["sample_freq"] = self.config.sweep_rate
        # The hardware of UART/SPI limits the sweep rate.
        self.config.gain = 0.7  # Gain between 0 and 1. Larger gain increase the SNR, but come at a cost
        # with more instability. Optimally is around 0.7
        self.info = self.client.setup_session(self.config)  # Setup acconeer radar session
        self.data_length = self.info["data_length"]  # Length of data per sample

        # Variables for tracking method
        self.first_data = True      # first time data is processed
        self.dt = 1 / self.list_of_variables_for_threads["sample_freq"]
        self.low_pass_const = self.low_pass_filter_constants_function(
            0.25, self.dt)  # Constant for a small
        # low-pass filter to smooth the changes. tau changes the filter weight, lower tau means shorter delay.
        # Usually tau = 0.25 is good.
        self.number_of_averages = 2  # Number of averages for tracked peak
        self.plot_time_length = 10  # Length of plotted data
        # Number of time samples when plotting
        self.number_of_time_samples = int(self.plot_time_length / self.dt)
        self.tracked_distance_over_time = np.zeros(
            self.number_of_time_samples)  # Array for distance over time plot
        self.local_peaks_index = []  # Index of big local peaks
        self.track_peak_index = []  # Index of last tracked peaks
        self.track_peaks_average_index = None  # Average of last tracked peaks
        self.threshold = 1  # Threshold for removing small local peaks. Start value not important

        # Returned variables
        self.tracked_distance = None  # distance to the tracked peak (m)
        self.tracked_amplitude = None
        self.tracked_phase = None
        self.tracked_data = None  # the final tracked data that is returned

        # Variables for phase to distance and plotting
        self.low_pass_amplitude = None  # low pass filtered amplitude
        self.low_pass_track_peak = None
        self.track_peak_relative_position = None  # used for plotting
        # the relative distance that is measured from phase differences (mm)
        self.relative_distance = 0  # relative distance to signal process
        self.real_time_breathing_amplitude = 0  # to send to the application
        self.last_phase = 0  # tracked phase from previous loop
        # saves old values to remove bias in real time breathing plot
        self.old_realtime_breathing_amplitude = np.zeros(1000)
        self.c = 2.998e8  # light speed (m/s)
        self.freq = 60e9  # radar frequency (Hz)
        self.wave_length = self.c / self.freq  # wave length of the radar
        self.delta_distance = 0  # difference in distance between the last two phases (m)
        self.delta_distance_low_pass = 0  # low pass filtered delta distance for plotting
        self.noise_run_time = 0  # number of run times with noise, used to remove noise
        self.not_noise_run_time = 0  # number of run times without noise

        # other
        # how often values are plotted and sent to the app
        self.modulo_base = int(self.list_of_variables_for_threads["sample_freq"] / 10)
        if self.modulo_base == 0:
            self.modulo_base = 1
        print('modulo base', self.modulo_base)
        self.run_times = 0  # number of times run in run
        self.calibrating_time = 5  # Time sleep for passing through filters. Used for Real time breathing

        # Graphs
        self.plot_graphs = False  # if plot the graphs or not
        if self.plot_graphs:
            self.pg_updater = PGUpdater(self.config)
            self.pg_process = PGProcess(self.pg_updater)
            self.pg_process.start()
        # acconeer graph
        self.low_pass_vel = 0
        self.hist_vel = np.zeros(self.number_of_time_samples)
        self.hist_pos = np.zeros(self.number_of_time_samples)
        self.last_data = None  # saved old data

        # filter
        self.highpass_HR = filter.Filter('highpass_HR')
        self.lowpass_HR = filter.Filter('lowpass_HR')
        self.highpass_RR = filter.Filter('highpass_RR')
        self.lowpass_RR = filter.Filter('lowpass_RR')

        self.HR_filtered_queue = list_of_variables_for_threads["HR_filtered_queue"]
        self.RR_filtered_queue = list_of_variables_for_threads["RR_filtered_queue"]
        # TODO remove
        self.RTB_final_queue = list_of_variables_for_threads["RTB_final_queue"]

        self.amp_data = []
Exemplo n.º 19
0
 def __init__(self, demo_ctrl, params):
     super().__init__(demo_ctrl, self.detector_name)
     self.config = configs.IQServiceConfig()
     self.update_config(params)
Exemplo n.º 20
0
def get_base_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.4, 0.8]
    config.sweep_rate = 60
    config.gain = 0.6
    return config
def get_base_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.1, 0.5]
    config.sweep_rate = int(np.ceil(max_speed * 4 / wavelength))
    config.gain = 0.7
    return config
Exemplo n.º 22
0
def get_base_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.3, 0.9]
    config.sweep_rate = 40
    config.gain = 0.7
    return config
Exemplo n.º 23
0
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)
    elif args.spi:
        client = RegSPIClient()
    else:
        port = args.serial_port or example_utils.autodetect_serial_port()
        client = RegClient(port)

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

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

    amplitude_y_max = 0.3

    fig, (amplitude_ax, phase_ax) = plt.subplots(2)
    fig.set_size_inches(8, 6)
    fig.canvas.set_window_title("Acconeer matplotlib example")

    for ax in [amplitude_ax, phase_ax]:
        ax.set_xlabel("Depth (m)")
        ax.set_xlim(config.range_interval)
        ax.grid(True)

    amplitude_ax.set_ylabel("Amplitude")
    amplitude_ax.set_ylim(0, 1.1 * amplitude_y_max)
    phase_ax.set_ylabel("Phase")
    example_utils.mpl_setup_yaxis_for_phase(phase_ax)

    xs = np.linspace(*config.range_interval, num_points)
    amplitude_line = amplitude_ax.plot(xs, np.zeros_like(xs))[0]
    phase_line = phase_ax.plot(xs, np.zeros_like(xs))[0]

    fig.tight_layout()
    plt.ion()
    plt.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()

        amplitude = np.abs(sweep)
        phase = np.angle(sweep)

        max_amplitude = np.max(amplitude)
        if max_amplitude > amplitude_y_max:
            amplitude_y_max = max_amplitude
            amplitude_ax.set_ylim(0, 1.1 * max_amplitude)

        amplitude_line.set_ydata(amplitude)
        phase_line.set_ydata(phase)

        if not plt.fignum_exists(1):  # Simple way to check if plot is closed
            break

        fig.canvas.flush_events()

    print("Disconnecting...")
    plt.close()
    client.disconnect()
Exemplo n.º 24
0
def get_sensor_config():
    config = configs.IQServiceConfig()
    config.range_interval = [0.1, 0.5]
    config.sweep_rate = int(np.ceil(MAX_SPEED * 4 / WAVELENGTH))
    config.gain = 0.7
    return config