example_waste_level.h
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2024
2 // All rights reserved
3 // This file is subject to the terms and conditions defined in the file
4 // 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
5 // of this source code package.
6 
7 #ifndef EXAMPLE_WASTE_LEVEL_H_
8 #define EXAMPLE_WASTE_LEVEL_H_
9 
10 #include <stdbool.h>
11 #include <stdint.h>
12 
13 #include "acc_config.h"
14 #include "acc_processing.h"
15 
16 /**
17  * @brief Waste level handle
18  */
20 
21 /**
22  * @brief Configuration for waste_level
23  */
24 typedef struct
25 {
26  /** Minimum detection distance from sensor */
27  float bin_start_m;
28 
29  /** Maximum detection distance from sensor */
30  float bin_end_m;
31 
32  /** Threshold for which the standard deviation of the phase should be below */
33  float threshold;
34 
35  /** Number of distance needed in sequence below threshold to be presumed as waste level */
37 
38  /** Length of the median filter used to stabilize the level result */
41 
42 typedef struct
43 {
44  /** Processing configuration */
46 
47  /** Sensor configuration */
50 
51 /**
52  * @brief Waste level preset
53  */
54 typedef enum
55 {
59 
60 /**
61  * @brief Result type
62  */
63 typedef struct
64 {
65  /** True if a level was found, false otherwise.
66  * Note: The other fields are valid if and only if level_found == true.
67  */
69 
70  /** The fill level in meters, measured from the bottom. */
71  float level_m;
72 
73  /** The fill level in percent. */
74  uint8_t level_percent;
76 
77 /**
78  * @brief Create a waste level app config (includes an acc_config_t)
79  */
81 
82 /**
83  * @brief Destroy a waste level app config
84  *
85  * @param[in] app_config The config to destroy
86  */
88 
89 /**
90  * @brief Apply a preset to an app config
91  *
92  * @param[in] preset The preset
93  * @param[in] app_config The waste level app config
94  */
96 
97 /**
98  * @brief Create a waste level handle
99  *
100  * The handle is used only for processing
101  *
102  * @param[in] app_config Waste level app configuration
103  * @return A waste_level handle, or NULL if creation failed
104  */
106 
107 /**
108  * @brief Destroy a waste level handle
109  *
110  * @param[in] handle The waste_level handle to destroy
111  */
113 
114 /**
115  * @brief Process Sparse IQ data
116  *
117  * @param[in] handle The waste level handle
118  * @param[in] app_config The waste level app configuration handle was created with
119  * @param[in] metadata The processing metadata
120  * @param[in] frame The Sparse IQ frame
121  * @param[out] waste_level_result Result processed by waste_level
122  */
124  const waste_level_app_config_t *app_config,
125  const acc_processing_metadata_t *metadata,
126  const acc_int16_complex_t *frame,
127  waste_level_result_t *waste_level_result);
128 
129 /**
130  * @brief Log a waste level config
131  *
132  * @param[in] config The waste level config
133  */
135 
136 #endif
waste_level_processing_config_t::distance_sequence_len
uint16_t distance_sequence_len
Definition: example_waste_level.h:36
waste_level_preset_t
waste_level_preset_t
Waste level preset.
Definition: example_waste_level.h:54
waste_level_handle_create
waste_level_handle_t * waste_level_handle_create(const waste_level_app_config_t *app_config)
Create a waste level handle.
Definition: example_waste_level.c:217
waste_level_result_t::level_m
float level_m
Definition: example_waste_level.h:71
waste_level_handle
Definition: example_waste_level.c:27
acc_int16_complex_t
Data type for interger-based representation of complex numbers.
Definition: acc_definitions_common.h:40
waste_level_handle_destroy
void waste_level_handle_destroy(waste_level_handle_t *handle)
Destroy a waste level handle.
Definition: example_waste_level.c:257
waste_level_result_t
Result type.
Definition: example_waste_level.h:63
waste_level_processing_config_t::median_filter_len
uint16_t median_filter_len
Definition: example_waste_level.h:39
config
cargo_config_t config
Definition: i2c_example_cargo.c:34
acc_processing_metadata_t
Metadata that will be populated by the processing module during creation.
Definition: acc_processing.h:36
waste_level_app_config_t
Definition: example_waste_level.h:42
waste_level_app_config_destroy
void waste_level_app_config_destroy(waste_level_app_config_t *app_config)
Destroy a waste level app config.
Definition: example_waste_level.c:166
waste_level_result_t::level_percent
uint8_t level_percent
Definition: example_waste_level.h:74
waste_level_processing_config_t::bin_start_m
float bin_start_m
Definition: example_waste_level.h:27
handle
cargo_handle_t * handle
Definition: i2c_example_cargo.c:35
acc_config_t
struct acc_config acc_config_t
Definition: acc_config.h:24
WASTE_LEVEL_PRESET_PLASTIC_WASTE_BIN
@ WASTE_LEVEL_PRESET_PLASTIC_WASTE_BIN
Definition: example_waste_level.h:57
WASTE_LEVEL_PRESET_NONE
@ WASTE_LEVEL_PRESET_NONE
Definition: example_waste_level.h:56
waste_level_processing_config_t::threshold
float threshold
Definition: example_waste_level.h:33
waste_level_app_config_t::sensor_config
acc_config_t * sensor_config
Definition: example_waste_level.h:48
waste_level_process
void waste_level_process(waste_level_handle_t *handle, const waste_level_app_config_t *app_config, const acc_processing_metadata_t *metadata, const acc_int16_complex_t *frame, waste_level_result_t *waste_level_result)
Process Sparse IQ data.
Definition: example_waste_level.c:275
waste_level_result_t::level_found
bool level_found
Definition: example_waste_level.h:68
acc_config.h
waste_level_processing_config_t
Configuration for waste_level.
Definition: example_waste_level.h:24
waste_level_app_config_create
waste_level_app_config_t * waste_level_app_config_create(void)
Create a waste level app config (includes an acc_config_t)
Definition: example_waste_level.c:147
waste_level_app_config_set_preset
void waste_level_app_config_set_preset(waste_level_preset_t preset, waste_level_app_config_t *app_config)
Apply a preset to an app config.
Definition: example_waste_level.c:179
waste_level_processing_config_log
void waste_level_processing_config_log(const waste_level_processing_config_t *config)
Log a waste level config.
Definition: example_waste_level.c:354
waste_level_processing_config_t::bin_end_m
float bin_end_m
Definition: example_waste_level.h:30
acc_processing.h
waste_level_app_config_t::processing_config
waste_level_processing_config_t processing_config
Definition: example_waste_level.h:45