examples/a121/extended_config.py

examples/a121/extended_config.py#

 1# Copyright (c) Acconeer AB, 2022-2024
 2# All rights reserved
 3
 4import acconeer.exptool as et
 5from acconeer.exptool import a121
 6
 7
 8args = a121.ExampleArgumentParser().parse_args()
 9et.utils.config_logging(args)
10
11client = a121.Client.open(**a121.get_client_args(args))
12
13# Assign a sensor ID from a board or module or evaluation kit (EVK)
14sensor_id = 1
15
16# Create a SessionConfig with (e.g.) two groups sensor configurations
17# SessionConfig is assigned 10 sweeps per frame in the first group, and 20 sweeps per frame in the second group
18# Unassigned configuration parameters will be assigned a default value
19session_config = a121.SessionConfig(
20    [
21        {  # First group
22            sensor_id: a121.SensorConfig(
23                sweeps_per_frame=10,
24            )
25        },
26        {  # Second group
27            sensor_id: a121.SensorConfig(
28                sweeps_per_frame=20,
29            )
30        },
31    ],
32    extended=True,
33)
34
35client.setup_session(session_config)
36client.start_session()
37
38for i in range(3):
39    extended_result = client.get_next()
40    # The result will contain two groups, each containing the output from one of the two SensorConfigs created above
41    # Here is how to get the result from the first group
42    result_first_group = extended_result[0]
43
44    # Get result for the selected sensor ID (It corresponds to the SensorConfig in the first group)
45    result_first_sensor_config = result_first_group[sensor_id]
46
47    # Extract the 'frame' data from first sensor result
48    first_frame = result_first_sensor_config.frame
49
50    # Extract the 'tick time' from second sensor result, time information when the data was captured
51    result_second_group = extended_result[1]
52    result_second_sensor_config = result_second_group[sensor_id]
53    second_tick_time = result_second_sensor_config.tick_time
54
55    print(f"\nExtended result {i + 1}:")
56    print(extended_result)
57    print(f"\nFrame from first sensor config {i + 1}:")
58    print(first_frame)
59    print(f"\nTick time from second sensor config {i + 1}:")
60    print(second_tick_time)
61
62client.stop_session()
63client.close()

View this example on GitHub: acconeer/acconeer-python-exploration