def main(): args = utils.ExampleArgumentParser().parse_args() utils.config_logging(args) if args.socket_addr: client = clients.SocketClient(args.socket_addr) elif args.spi: client = clients.SPIClient() else: port = args.serial_port or utils.autodetect_serial_port() client = clients.UARTClient(port) config = configs.EnvelopeServiceConfig() config.sensor = args.sensors print(config) connect_info = client.connect() print("connect info:") print_dict(connect_info) session_info = client.start_session(config) print("session_info:") print_dict(session_info) data_info, data = client.get_next() print("data_info:") print_dict(data_info) client.disconnect()
def get_sensor_config(): config = configs.EnvelopeServiceConfig() config.range_interval = [0.5, 1.5] config.hw_accelerated_average_samples = 15 config.update_rate = None return config
def initialize(): ''' ********************************** Initialize: Call once at beginning ********************************** ''' client.squeeze = False sensor_config = configs.EnvelopeServiceConfig() sensor_config.sensor = 1 sensor_config.range_interval = [0.2, 1.0] sensor_config.profile = sensor_config.Profile.PROFILE_2 sensor_config.hw_accelerated_average_samples = 20 sensor_config.downsampling_factor = 2 sensor_config.repetition_mode = configs.EnvelopeServiceConfig.RepetitionMode.SENSOR_DRIVEN sensor_config.update_rate = 10 * numtries # period of 100ms #print(sensor_config) session_info = client.setup_session(sensor_config) #print(session_info) #pg_updater = PGUpdater(sensor_config, None, session_info) #pg_process = PGProcess(pg_updater) #pg_process.start() client.start_session() '''
def test_unknown_mode(): config = configs.EnvelopeServiceConfig() mocker = clients.MockClient() mocker.squeeze = False session_info = mocker.start_session(config) recorder = recording.Recorder(sensor_config=config, session_info=session_info) data_info, data = mocker.get_next() recorder.sample(data_info, data) recorder.close() record = recorder.record packed = recording.pack(record) assert "mode" in packed with pytest.warns(None) as captured_warnings: recording.unpack(packed) assert len(captured_warnings) == 0 with pytest.warns(UserWarning): packed["mode"] = "some_unknown_mode" unpacked = recording.unpack(packed) assert (unpacked.mode is None)
def get_sensor_config(): config = configs.EnvelopeServiceConfig() config.range_interval = [0.2, 0.6] config.update_rate = 40 config.gain = 0.5 config.running_average_factor = 0 # Use averaging in detector instead of in API return config
def get_sensor_config(): config = configs.EnvelopeServiceConfig() config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_1 config.range_interval = [0.04, 0.05] config.running_average_factor = 0.01 config.maximize_signal_attenuation = True config.update_rate = 60 config.gain = 0.2 config.repetition_mode = configs.EnvelopeServiceConfig.RepetitionMode.SENSOR_DRIVEN return config
def test_run_a_host_driven_session(setup): client, sensor = setup config = configs.EnvelopeServiceConfig() config.sensor = sensor config.repetition_mode = configs.EnvelopeServiceConfig.RepetitionMode.HOST_DRIVEN client.start_session(config) client.get_next() client.stop_session()
def get_sensor_config(): config = configs.EnvelopeServiceConfig() config.downsampling_factor = 2 config.range_interval = [0.12, 0.62] config.running_average_factor = 0 config.update_rate = 0.5 config.hw_accelerated_average_samples = 20 config.power_save_mode = configs.BaseServiceConfig.PowerSaveMode.OFF config.asynchronous_measurement = False return config
def test_run_a_sensor_driven_session(setup): client, sensor = setup config = configs.EnvelopeServiceConfig() config.sensor = sensor config.repetition_mode = configs.EnvelopeServiceConfig.RepetitionMode.SENSOR_DRIVEN config.update_rate = 10 client.start_session(config) client.get_next() client.stop_session()
def main(): client = clients.UARTClient("/dev/ttyUSB1") client.squeeze = False sensor_config = configs.EnvelopeServiceConfig() sensor_config.sensor = 1 sensor_config.range_interval = [0.2, 1.0] sensor_config.profile = sensor_config.Profile.PROFILE_2 sensor_config.hw_accelerated_average_samples = 20 sensor_config.downsampling_factor = 2 session_info = client.setup_session(sensor_config) client.start_session()
def test_value_dump_load(): conf = configs.SparseServiceConfig() assert conf.downsampling_factor == 1 conf.downsampling_factor = 2 dump = conf._dumps() conf = configs.SparseServiceConfig() assert conf.downsampling_factor == 1 conf._loads(dump) assert conf.downsampling_factor == 2 conf = configs.EnvelopeServiceConfig() with pytest.raises(AssertionError): conf._loads(dump)
def main(): args = utils.ExampleArgumentParser().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) # 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.update_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_session() # 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 = 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()
def main(): args = utils.ExampleArgumentParser().parse_args() utils.config_logging(args) if args.socket_addr: client = clients.SocketClient(args.socket_addr) elif args.spi: client = clients.SPIClient() else: port = args.serial_port or utils.autodetect_serial_port() client = clients.UARTClient(port) client.squeeze = False sensor_config = configs.EnvelopeServiceConfig() sensor_config.sensor = args.sensors sensor_config.range_interval = [0.2, 1.0] sensor_config.profile = sensor_config.Profile.PROFILE_2 sensor_config.hw_accelerated_average_samples = 20 sensor_config.downsampling_factor = 2 session_info = client.setup_session(sensor_config) pg_updater = PGUpdater(sensor_config, None, session_info) pg_process = PGProcess(pg_updater) pg_process.start() client.start_session() interrupt_handler = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session") while not interrupt_handler.got_signal: data_info, data = client.get_next() try: pg_process.put_data(data) except PGProccessDiedException: break print("Disconnecting...") pg_process.close() client.disconnect()
def main(): args = utils.ExampleArgumentParser().parse_args() utils.config_logging(args) filename = "data.h5" if os.path.exists(filename): print("File '{}' already exists, won't overwrite".format(filename)) sys.exit(1) 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) recorder = recording.Recorder(sensor_config=config, session_info=session_info) client.start_session() n = 100 for i in range(n): data_info, data = client.get_next() recorder.sample(data_info, data) print("Sampled {:>4}/{}".format(i + 1, n), end="\r", flush=True) print() client.disconnect() record = recorder.close() os.makedirs(os.path.dirname(filename), exist_ok=True) recording.save(filename, record) print("Saved to '{}'".format(filename))
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"] == "1": self.config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_1 elif params["profile"] == "2": self.config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_2 elif params["profile"] == "3": self.config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_3 elif params["profile"] == "4": self.config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_4 elif params["profile"] == "5": self.config.profile = configs.EnvelopeServiceConfig.Profile.PROFILE_5 else: print("Unknown profile")
def test_recording(tmp_path): config = configs.EnvelopeServiceConfig() config.downsampling_factor = 2 mocker = clients.MockClient() mocker.squeeze = False session_info = mocker.start_session(config) recorder = recording.Recorder( sensor_config=config, session_info=session_info, ) for _ in range(10): data_info, data = mocker.get_next() recorder.sample(data_info, data) recorder.close() record = recorder.record assert record.mode == modes.Mode.ENVELOPE assert record.sensor_config_dump == config._dumps() assert len(record.data) == 10 assert len(record.data_info) == 10 assert isinstance(record.data, np.ndarray) for ext in ["h5", "npz"]: filename = os.path.join(tmp_path, "record." + ext) recording.save(filename, record) loaded_record = recording.load(filename) for a in attr.fields(recording.Record): if a.name == "data": continue assert getattr(record, a.name) == getattr(loaded_record, a.name) assert np.all(record.data == loaded_record.data) assert record.sensor_config.downsampling_factor == config.downsampling_factor
def test_run_illegal_config(setup): client, sensor = setup if isinstance(client, clients.MockClient): return config = configs.EnvelopeServiceConfig() config.sensor = sensor config.repetition_mode = configs.EnvelopeServiceConfig.RepetitionMode.SENSOR_DRIVEN config.update_rate = 10 config.range_interval = [0.2, 2.0] # too long without stitching with pytest.raises(clients.base.IllegalConfigError): client.setup_session(config) with pytest.raises(clients.base.SessionSetupError): client.setup_session(config, check_config=False) config.range_interval = [0.2, 0.4] client.start_session(config) client.get_next() client.stop_session()
def main(): args = utils.ExampleArgumentParser().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) # 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, 1] # Range configuration config.update_rate = 50 # Data collection frequency 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_session() # 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 = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session\n") # Here we make use of multiprocessing to run the data collection, sound wave computation, and # audio output separately. the intrerrupt_handler is passed in # so that the processes are stopped when a user hits Ctrl-C. with multiprocessing.Manager() as manager: shared_value = manager.Value( 'd', 0) # Shared variable to control the determined frequency. shared_amp = manager.Value( 'd', 0) # Shared variable to control when a sound should be played. shared_wave = multiprocessing.Array('d', 4410) # Shared Array p1 = multiprocessing.Process(target=data_handler, args=(client, interrupt_handler, shared_value, shared_amp)) p2 = multiprocessing.Process(target=tune_gen, args=(interrupt_handler, shared_value, shared_amp, shared_wave)) p3 = multiprocessing.Process(target=tune_play, args=(interrupt_handler, shared_wave)) # Start processes p1.start() p2.start() p3.start() # Wait for processes to terminate before moving on p1.join() p2.join() p3.join() print("Disconnecting...") client.disconnect()
def main(): # To simplify the examples, we use a generic argument parser. It # lets you choose between UART/SPI/socket, set which sensor(s) to # use, and the verbosity level of the logging. args = utils.ExampleArgumentParser().parse_args() # The client logs using the logging module with a logger named # acconeer.exptool.*. 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 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 utils.autodetect_serial_port() client = UARTClient(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.update_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 the session. This call will block until the sensor has # confirmed that it has started. client.start_session() # Alternatively, start_session can be given the config instead. In # that case, the client will call setup_session(config) for you # before starting the session. For example: # session_info = client.start_session(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. f = open("demo.txt","a"); for i in range(3): data_info, data = client.get_next() print("Sweep {}:\n".format(i + 1), data_info, "\n", data, "\n") f.write(numpy.array2string(data) + "\n") f.close() # We're done, stop the session. All buffered/waiting data is thrown # away. This call will block until the server has confirmed that the # session has ended. client.stop_session() # Calling stop_session before disconnect is not necessary as # disconnect will call stop_session if a session is started. # Remember to always call disconnect to do so gracefully client.disconnect()
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()
def main(): args = utils.ExampleArgumentParser().parse_args() utils.config_logging(args) if args.socket_addr: client = clients.SocketClient(args.socket_addr) elif args.spi: client = clients.SPIClient() else: port = args.serial_port or utils.autodetect_serial_port() client = clients.UARTClient(port) client.squeeze = False sensor_config = configs.EnvelopeServiceConfig() sensor_config.sensor = args.sensors sensor_config.range_interval = [0.2, 1.0] sensor_config.profile = sensor_config.Profile.PROFILE_2 sensor_config.hw_accelerated_average_samples = 20 sensor_config.downsampling_factor = 2 session_info = client.setup_session(sensor_config) pg_updater = PGUpdater(sensor_config, None, session_info) pg_process = PGProcess(pg_updater) #pg_process.start() client.start_session() interrupt_handler = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session") f = open("demo.txt", "w") while not interrupt_handler.got_signal: data_info, data = client.get_next() tempstr = " " #Array is within another Array, need to get address internal array dataArray = data[0] localMaxArray = [0, 0] breakVariable = 0 iteratorJ = 0 iteratorI = 0 for x in dataArray: if (iteratorJ > 10): localMaxArray[0] = iteratorI - iteratorJ break else: if (x >= localMaxArray[0]): localMaxArray[0] = x iteratorJ = 0 else: iteratorJ = iteratorJ + 1 iteratorI = iteratorI + 1 while (dataArray[iteratorI] >= dataArray[iteratorI + 1]): iteratorI = iteratorI + 1 iteratorJ = 0 while (iteratorI < 827): if (iteratorJ > 10): localMaxArray[1] = iteratorI - iteratorJ break else: if (dataArray[iteratorI] >= localMaxArray[1]): localMaxArray[1] = dataArray[iteratorI] iteratorJ = 0 else: iteratorJ = iteratorJ + 1 iteratorI = iteratorI + 1 #try: #pg_process.put_data(data) #except PGProccessDiedException: #break print( math.floor( (((localMaxArray[1] - localMaxArray[0]) / 1.773) * 0.0393701) * 10) / 10) print("Disconnecting...") f.close() #pg_process.close() client.disconnect()
def main(): parser = utils.ExampleArgumentParser() parser.add_argument("-o", "--output-dir", type=str, required=True) parser.add_argument("--file-format", type=str, default="h5") parser.add_argument("--frames-per-file", type=int, default=10000) args = parser.parse_args() utils.config_logging(args) if os.path.exists(args.output_dir): print("Directory '{}' already exists, won't overwrite".format(args.output_dir)) sys.exit(1) file_format = args.file_format.lower() if file_format == "np": file_format = "npz" if file_format not in ["h5", "npz"]: print("Unknown format '{}'".format(args.file_format)) sys.exit(1) if args.frames_per_file < 10: print("Frames per file must be at least 10") sys.exit(1) 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.start_session(config) os.makedirs(args.output_dir) interrupt_handler = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session") total_num_frames = 0 while not interrupt_handler.got_signal: record_count, num_frames_in_record = divmod(total_num_frames, args.frames_per_file) if num_frames_in_record == 0: recorder = recording.Recorder(sensor_config=config, session_info=session_info) data_info, data = client.get_next() recorder.sample(data_info, data) if num_frames_in_record + 1 == args.frames_per_file: record = recorder.close() filename = os.path.join( args.output_dir, "{:04}.{}".format(record_count + 1, file_format)) print("Saved", filename) recording.save(filename, record) total_num_frames += 1 print("Sampled {:>5}".format(total_num_frames), end="\r", flush=True) try: client.disconnect() except Exception: pass record_count, num_frames_in_record = divmod(total_num_frames, args.frames_per_file) if num_frames_in_record > 0: record = recorder.close() filename = os.path.join( args.output_dir, "{:04}.{}".format(record_count + 1, file_format)) print("Saved", filename) recording.save(filename, record)
def main(): args = utils.ExampleArgumentParser().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) # 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.4, 0.7] config.update_rate = 20 config.profile = config.Profile.PROFILE_2 config.hw_accelerated_average_samples = 20 config.downsampling_factor = 2 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_session() # 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 = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session\n") is_performance_test_done = False while not interrupt_handler.got_signal: info, data = client.get_next() my_data = list(data) # Get the index of the highest measured signal strength from the list. index_max_signal_strength = my_data.index(max(my_data)) # Calculate the distance of the highest measured signal strength in meters. if max(my_data) > 400: distance_of_strongest_signal_strength = 0.4 + ( index_max_signal_strength * session_info["step_length_m"]) else: distance_of_strongest_signal_strength = 1000 print("No strong signal") #print(distance_of_strongest_signal_strength) #print("meters, signal strength : ") #print(index_max_signal_strength) #print("\r") print(max(my_data)) # Run a performance test. if is_performance_test_done is False: is_performance_test_done = run_test( distance_of_strongest_signal_strength) print("Disconnecting...") client.disconnect()
def main(): parser = utils.ExampleArgumentParser() parser.add_argument("-o", "--output-file", type=str, required=True) parser.add_argument("-l", "--limit-frames", type=int) args = parser.parse_args() utils.config_logging(args) if os.path.exists(args.output_file): print("File '{}' already exists, won't overwrite".format( args.output_file)) sys.exit(1) _, ext = os.path.splitext(args.output_file) if ext.lower() not in [".h5", ".npz"]: print("Unknown format '{}'".format(ext)) sys.exit(1) if args.limit_frames is not None and args.limit_frames < 1: print("Frame limit must be at least 1") sys.exit(1) 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) recorder = recording.Recorder(sensor_config=config, session_info=session_info) client.start_session() interrupt_handler = utils.ExampleInterruptHandler() print("Press Ctrl-C to end session") i = 0 while not interrupt_handler.got_signal: data_info, data = client.get_next() recorder.sample(data_info, data) i += 1 if args.limit_frames: print("Sampled {:>4}/{}".format(i, args.limit_frames), end="\r", flush=True) if i >= args.limit_frames: break else: print("Sampled {:>4}".format(i), end="\r", flush=True) print() client.disconnect() record = recorder.close() os.makedirs(os.path.dirname(os.path.abspath(args.output_file)), exist_ok=True) recording.save(args.output_file, record) print("Saved to '{}'".format(args.output_file))