example_cargo.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2025
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 #include <stdbool.h>
8 #include <stddef.h>
9
10 #include "acc_config.h"
11 #include "acc_detector_distance.h"
12 #include "acc_detector_presence.h"
13 #include "acc_integration.h"
14 #include "acc_integration_log.h"
15 #include "acc_sensor.h"
16 #include "example_cargo.h"
17
18 #define MODULE "example_cargo"
19 #define CARGO_CONFIG_MAGIC 0xACC0CA60
20 #define CARGO_PRESENCE_RUN_TIME_S 5.0f
21 #define CARGO_PRESENCE_MIN_UPDATE_RATE 1.0f
22 #define CARGO_PRESENCE_MIN_SWEEPS_PER_FRAME 4U
23
24 /**
25 * @brief Cargo handle
26 */
27 struct cargo_handle
28 {
29 acc_detector_distance_config_t *distance_config;
30 acc_detector_distance_handle_t *distance_handle;
31
32 acc_detector_presence_config_t *presence_config;
33 acc_detector_presence_handle_t *presence_handle;
34 acc_detector_presence_metadata_t presence_metadata;
35
36 /* fields in 'parameters' are config-dependent but does not change */
37 struct
38 {
39 cargo_container_size_t container_size;
40
41 uint16_t num_frames_distance_occupies_cargo_app;
42 uint16_t num_frames_presence_occupies_cargo_app;
43 uint16_t num_frames_presence_uses_same_filter;
44
45 } parameters;
46
47 /* fields in 'state' are config-dependent and changes as fast as every prepare/process */
48 struct
49 {
50 cargo_mode_t current_mode;
51
52 uint16_t num_distance_process_since_prepare;
53 uint16_t num_presence_process_since_prepare;
54 uint16_t num_presence_process_since_filter_reset;
55 } state;
56 };
57
58 //-----------------------------
59 // Private declarations
60 //-----------------------------
61
62 static bool validate_cargo_config(const cargo_config_t *cargo_config);
63
64 static bool populate_handle_with_distance_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle);
65
66 static bool populate_handle_with_presence_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle);
67
68 static bool translate_cargo_config_to_distance_config(const cargo_config_t *cargo_config, acc_detector_distance_config_t *distance_config);
69
70 static bool translate_cargo_config_to_presence_config(const cargo_config_t *cargo_config, acc_detector_presence_config_t *presence_config);
71
72 static uint16_t presence_calc_num_frames_per_burst(const cargo_config_t *cargo_config);
73
74 static float float_clip(float value, float min, float max);
75
76 //-----------------------------
77 // Public definitions
78 //-----------------------------
79
80 void cargo_config_initialize(cargo_config_t *cargo_config, cargo_preset_t preset)
81 {
82 bool status = cargo_config != NULL;
83
84 if (status)
85 {
86 // >>> base settings
87 cargo_config->activate_utilization_level = true;
88 cargo_config->activate_presence = false;
89
90 cargo_config->presence.update_rate = 6.0f;
91 cargo_config->presence.signal_quality = 20.0f;
92 cargo_config->presence.sweeps_per_frame = 12U;
93 cargo_config->presence.inter_detection_threshold = 4.0f;
94 cargo_config->presence.intra_detection_threshold = 2.75;
95 cargo_config->presence.rate_is_app_driven = false;
96
97 cargo_config->utilization.signal_quality = 10.0f;
98 cargo_config->utilization.threshold_sensitivity = 0.0f;
99 // <<< base settings
100
101 switch (preset)
102 {
103 case CARGO_PRESET_CONTAINER_10_FEET:
104 cargo_config->container_size = CARGO_CONTAINER_SIZE_10_FT;
105 break;
106 case CARGO_PRESET_CONTAINER_20_FEET:
107 cargo_config->container_size = CARGO_CONTAINER_SIZE_20_FT;
108 break;
109 case CARGO_PRESET_CONTAINER_40_FEET:
110 cargo_config->container_size = CARGO_CONTAINER_SIZE_40_FT;
111 break;
112 case CARGO_PRESET_NO_LENS:
113 cargo_config->container_size = CARGO_CONTAINER_SIZE_20_FT;
114
115 cargo_config->utilization.signal_quality = 25.0f;
116 cargo_config->utilization.threshold_sensitivity = 0.5f;
117
118 cargo_config->presence.signal_quality = 30.0f;
119 cargo_config->presence.inter_detection_threshold = 2.0f;
120 cargo_config->presence.intra_detection_threshold = 2.0f;
121 break;
122 default:
123 ACC_LOG_ERROR("Invalid preset");
124 status = false;
125 break;
126 }
127 }
128
129 if (status)
130 {
131 cargo_config->magic = CARGO_CONFIG_MAGIC;
132 }
133 }
134
135 void cargo_config_log(const cargo_config_t *cargo_config)
136 {
137 switch (cargo_config->container_size)
138 {
139 case CARGO_CONTAINER_SIZE_10_FT:
140 ACC_LOG_INFO("container_size: CARGO_CONTAINER_SIZE_10_FT");
141 break;
142 case CARGO_CONTAINER_SIZE_20_FT:
143 ACC_LOG_INFO("container_size: CARGO_CONTAINER_SIZE_20_FT");
144 break;
145 case CARGO_CONTAINER_SIZE_40_FT:
146 ACC_LOG_INFO("container_size: CARGO_CONTAINER_SIZE_40_FT");
147 break;
148 default:
149 ACC_LOG_INFO("container_size: ?");
150 break;
151 }
152
153 ACC_LOG_INFO("activate_utilization_level: %s", cargo_config->activate_utilization_level ? "true" : "false");
154 ACC_LOG_INFO("utilization.signal_quality: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->utilization.signal_quality));
155 ACC_LOG_INFO("utilization.threshold_sensitivity: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->utilization.threshold_sensitivity));
156 ACC_LOG_INFO("activate_presence: %s", cargo_config->activate_presence ? "true" : "false");
157 ACC_LOG_INFO("presence.update_rate: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->presence.update_rate));
158 ACC_LOG_INFO("presence.sweeps_per_frame: %" PRIu16, cargo_config->presence.sweeps_per_frame);
159 ACC_LOG_INFO("presence.signal_quality: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->presence.signal_quality));
160 ACC_LOG_INFO("presence.inter_detection_threshold: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->presence.inter_detection_threshold));
161 ACC_LOG_INFO("presence.intra_detection_threshold: %" PRIfloat, ACC_LOG_FLOAT_TO_INTEGER(cargo_config->presence.intra_detection_threshold));
162 }
163
164 cargo_handle_t *cargo_handle_create(const cargo_config_t *cargo_config)
165 {
166 cargo_handle_t *handle = NULL;
167 bool status = validate_cargo_config(cargo_config);
168
169 if (status)
170 {
171 handle = acc_integration_mem_calloc(1U, sizeof(*handle));
172 status = handle != NULL;
173 }
174
175 if (status)
176 {
177 handle->parameters.container_size = cargo_config->container_size;
178 handle->state.current_mode = CARGO_MODE_NONE;
179 handle->state.num_distance_process_since_prepare = UINT16_MAX;
180 handle->state.num_presence_process_since_prepare = UINT16_MAX;
181 handle->state.num_presence_process_since_filter_reset = UINT16_MAX;
182
183 if (cargo_config->activate_presence && cargo_config->activate_utilization_level)
184 {
185 if (!populate_handle_with_distance_resources(cargo_config, handle) || !populate_handle_with_presence_resources(cargo_config, handle))
186 {
187 status = false;
188 }
189 else
190 {
191 // presence handle is created with "reset" filters:
192 handle->state.num_presence_process_since_filter_reset = 0U;
193
194 handle->parameters.num_frames_distance_occupies_cargo_app = 1U;
195
196 uint16_t num_frames_per_burst = presence_calc_num_frames_per_burst(cargo_config);
197
198 handle->parameters.num_frames_presence_occupies_cargo_app = num_frames_per_burst;
199 handle->parameters.num_frames_presence_uses_same_filter = num_frames_per_burst;
200 }
201 }
202 else if (cargo_config->activate_utilization_level)
203 {
204 if (!populate_handle_with_distance_resources(cargo_config, handle))
205 {
206 status = false;
207 }
208 }
209 else if (cargo_config->activate_presence)
210 {
211 if (!populate_handle_with_presence_resources(cargo_config, handle))
212 {
213 status = false;
214 }
215 else
216 {
217 // presence handle is created with "reset" filters:
218 handle->state.num_presence_process_since_filter_reset = 0U;
219
220 uint16_t num_frames_per_burst = presence_calc_num_frames_per_burst(cargo_config);
221 handle->parameters.num_frames_presence_occupies_cargo_app = num_frames_per_burst;
222 handle->parameters.num_frames_presence_uses_same_filter = num_frames_per_burst;
223 }
224 }
225 else
226 {
227 // This is unreachable (path should be handled in validate_cargo_config)
228 status = false;
229 }
230 }
231
232 if (!status)
233 {
234 cargo_handle_destroy(handle);
235 }
236
237 return status ? handle : NULL;
238 }
239
240 void cargo_handle_destroy(cargo_handle_t *handle)
241 {
242 if (handle != NULL)
243 {
244 if (handle->distance_config != NULL)
245 {
246 acc_detector_distance_config_destroy(handle->distance_config);
247 handle->distance_config = NULL;
248 }
249
250 if (handle->distance_handle != NULL)
251 {
252 acc_detector_distance_destroy(handle->distance_handle);
253 handle->distance_handle = NULL;
254 }
255
256 if (handle->presence_config != NULL)
257 {
258 acc_detector_presence_config_destroy(handle->presence_config);
259 handle->presence_config = NULL;
260 }
261
262 if (handle->presence_handle != NULL)
263 {
264 acc_detector_presence_destroy(handle->presence_handle);
265 handle->presence_handle = NULL;
266 }
267
268 acc_integration_mem_free(handle);
269 }
270 }
271
272 bool cargo_get_buffer_size(const cargo_handle_t *handle, uint32_t *buffer_size)
273 {
274 bool status = (handle != NULL) && (buffer_size != NULL);
275
276 uint32_t ignored;
277 uint32_t distance_buffer_size = 0U;
278 uint32_t presence_buffer_size = 0U;
279
280 if (status && (handle->distance_handle != NULL))
281 {
282 status = acc_detector_distance_get_sizes(handle->distance_handle, &distance_buffer_size, &ignored);
283 }
284
285 if (status && (handle->presence_handle != NULL))
286 {
287 status = acc_detector_presence_get_buffer_size(handle->presence_handle, &presence_buffer_size);
288 }
289
290 if (status)
291 {
292 *buffer_size = distance_buffer_size > presence_buffer_size ? distance_buffer_size : presence_buffer_size;
293 }
294
295 return status;
296 }
297
298 bool cargo_get_distance_cal_result_static_size(const cargo_handle_t *handle, uint32_t *distance_cal_result_static_size)
299 {
300 bool status = (handle != NULL) && (distance_cal_result_static_size != NULL);
301
302 uint32_t ignored;
303 uint32_t res = 0U;
304
305 if (status && (handle->distance_handle != NULL))
306 {
307 status = acc_detector_distance_get_sizes(handle->distance_handle, &ignored, &res);
308 }
309
310 if (status)
311 {
312 *distance_cal_result_static_size = res;
313 }
314
315 return status;
316 }
317
318 bool cargo_calibrate(cargo_handle_t *handle,
319 acc_sensor_t *sensor,
320 const acc_cal_result_t *sensor_cal_result,
321 void *buffer,
322 uint32_t buffer_size,
323 uint8_t *distance_cal_result_static,
324 uint32_t distance_cal_result_static_size,
325 acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic,
326 bool *calibration_complete)
327 {
328 bool status = (handle != NULL) && (calibration_complete != NULL);
329
330 if (status)
331 {
332 if (handle->distance_handle == NULL)
333 {
334 *calibration_complete = true;
335 }
336 else
337 {
338 status = acc_detector_distance_calibrate(sensor,
339 handle->distance_handle,
340 sensor_cal_result,
341 buffer,
342 buffer_size,
343 distance_cal_result_static,
344 distance_cal_result_static_size,
345 distance_cal_result_dynamic,
346 calibration_complete);
347 }
348 }
349
350 return status;
351 }
352
353 bool cargo_update_calibration(cargo_handle_t *handle,
354 acc_sensor_t *sensor,
355 const acc_cal_result_t *sensor_cal_result,
356 void *buffer,
357 uint32_t buffer_size,
358 acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic,
359 bool *calibration_complete)
360 {
361 bool status = (handle != NULL) && (calibration_complete != NULL);
362
363 if (status)
364 {
365 if (handle->distance_handle == NULL)
366 {
367 *calibration_complete = true;
368 }
369 else
370 {
371 status = acc_detector_distance_update_calibration(sensor,
372 handle->distance_handle,
373 sensor_cal_result,
374 buffer,
375 buffer_size,
376 distance_cal_result_dynamic,
377 calibration_complete);
378 }
379 }
380
381 return status;
382 }
383
384 bool cargo_prepare_utilization(cargo_handle_t *handle,
385 acc_sensor_t *sensor,
386 const acc_cal_result_t *sensor_cal_result,
387 void *buffer,
388 uint32_t buffer_size)
389 {
390 bool status = (handle != NULL);
391
392 if (status)
393 {
394 switch (handle->state.current_mode)
395 {
396 case CARGO_MODE_NONE:
397 status =
398 acc_detector_distance_prepare(handle->distance_handle, handle->distance_config, sensor, sensor_cal_result, buffer, buffer_size);
399 if (status)
400 {
401 handle->state.current_mode = CARGO_MODE_UTILIZATION;
402 handle->state.num_distance_process_since_prepare = 0U;
403 }
404 break;
405 case CARGO_MODE_PRESENCE:
406 ACC_LOG_ERROR("Handle is currently in presence-mode. More calls to cargo_process_presence() is expected");
407 status = false;
408 break;
409 case CARGO_MODE_UTILIZATION:
410 ACC_LOG_ERROR("Handle has already prepared for utilization level measurement. More calls to cargo_process_utilization() is expected");
411 status = false;
412 break;
413 default:
414 ACC_LOG_ERROR("Unknown current mode");
415 status = false;
416 break;
417 }
418 }
419
420 return status;
421 }
422
423 bool cargo_prepare_presence(cargo_handle_t *handle,
424 acc_sensor_t *sensor,
425 const acc_cal_result_t *sensor_cal_result,
426 void *buffer,
427 uint32_t buffer_size)
428 {
429 bool status = (handle != NULL);
430
431 if (status)
432 {
433 switch (handle->state.current_mode)
434 {
435 case CARGO_MODE_NONE:
436 status =
437 acc_detector_presence_prepare(handle->presence_handle, handle->presence_config, sensor, sensor_cal_result, buffer, buffer_size);
438 if (status)
439 {
440 handle->state.current_mode = CARGO_MODE_PRESENCE;
441 handle->state.num_presence_process_since_prepare = 0U;
442 }
443 break;
444 case CARGO_MODE_PRESENCE:
445 ACC_LOG_ERROR("Handle has already prepared for presence measurement. More calls to cargo_process_utilization() is expected");
446 status = false;
447 break;
448 case CARGO_MODE_UTILIZATION:
449 ACC_LOG_ERROR("Handle is currently in utilization-mode. More calls to cargo_process_utilization() is expected");
450 status = false;
451 break;
452 default:
453 ACC_LOG_ERROR("Unknown current mode");
454 status = false;
455 break;
456 }
457 }
458
459 return status;
460 }
461
462 bool cargo_process_utilization(cargo_handle_t *handle,
463 uint8_t *distance_cal_result_static,
464 acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic,
465 void *buffer,
466 cargo_result_t *cargo_result,
467 bool *result_available,
468 acc_detector_distance_result_t *nullable_distance_result)
469 {
470 bool distance_result_available = false;
471 acc_detector_distance_result_t local_distance_result = {0};
472
473 acc_detector_distance_result_t *distance_result = nullable_distance_result != NULL ? nullable_distance_result : &local_distance_result;
474
475 bool status = (handle != NULL) && (cargo_result != NULL) && (result_available != NULL);
476
477 if (status)
478 {
479 cargo_result->utilization_valid = false;
480 cargo_result->presence_valid = false;
481
482 switch (handle->state.current_mode)
483 {
484 case CARGO_MODE_UTILIZATION:
485 {
486 if (acc_detector_distance_process(handle->distance_handle,
487 buffer,
488 distance_cal_result_static,
489 distance_cal_result_dynamic,
490 &distance_result_available,
491 distance_result))
492 {
493 handle->state.num_distance_process_since_prepare++;
494
495 *result_available = distance_result_available;
496
497 if (distance_result->num_distances > 0U)
498 {
499 float distance_m = distance_result->distances[0];
500
501 float container_size_length_m = 0.0f;
502 switch (handle->parameters.container_size)
503 {
504 case CARGO_CONTAINER_SIZE_10_FT:
505 container_size_length_m = 3.0f;
506 break;
507 case CARGO_CONTAINER_SIZE_20_FT:
508 container_size_length_m = 6.0f;
509 break;
510 case CARGO_CONTAINER_SIZE_40_FT:
511 container_size_length_m = 12.0f;
512 break;
513 default:
514 ACC_LOG_ERROR("Unexpected container_size_t");
515 status = false;
516 break;
517 }
518
519 cargo_result->utilization_valid = true;
520
521 cargo_result->distance = distance_m;
522 cargo_result->level_m = float_clip(container_size_length_m - distance_m, 0.0f, container_size_length_m);
523 cargo_result->level_percent = float_clip(cargo_result->level_m / container_size_length_m * 100.0f, 0.0f, 100.0f);
524
525 cargo_result->calibration_needed = distance_result->processing_result->calibration_needed;
526 }
527 }
528 else
529 {
530 ACC_LOG_ERROR("distance detector processing failed");
531 status = false;
532 }
533
534 if (handle->state.num_distance_process_since_prepare >= handle->parameters.num_frames_distance_occupies_cargo_app)
535 {
536 handle->state.current_mode = CARGO_MODE_NONE;
537 }
538 }
539 break;
540 case CARGO_MODE_PRESENCE:
541 ACC_LOG_ERROR("Handle is in presence-mode. Call cargo_process_presence() instead");
542 status = false;
543 break;
544 case CARGO_MODE_NONE:
545 ACC_LOG_ERROR("cargo_prepare_utilization() have not been called beforehand");
546 status = false;
547 break;
548 default:
549 ACC_LOG_ERROR("Unknown current mode");
550 status = false;
551 break;
552 }
553 }
554
555 return status;
556 }
557
558 bool cargo_process_presence(cargo_handle_t *handle,
559 void *buffer,
560 cargo_result_t *cargo_result,
561 acc_detector_presence_result_t *nullable_presence_result)
562 {
563
564 acc_detector_presence_result_t local_presence_result = {0};
565 acc_detector_presence_result_t *presence_result = nullable_presence_result != NULL ? nullable_presence_result : &local_presence_result;
566
567 bool status = (handle != NULL) && (cargo_result != NULL);
568
569 if (status)
570 {
571 cargo_result->utilization_valid = false;
572 cargo_result->presence_valid = false;
573
574 switch (handle->state.current_mode)
575 {
576 case CARGO_MODE_PRESENCE:
577 {
578 status = acc_detector_presence_process(handle->presence_handle, buffer, presence_result);
579 if (status)
580 {
581 handle->state.num_presence_process_since_prepare++;
582 handle->state.num_presence_process_since_filter_reset++;
583
584 cargo_result->presence_valid = true;
585
586 cargo_result->presence_detected = presence_result->presence_detected;
587 cargo_result->inter_presence_score = presence_result->inter_presence_score;
588 cargo_result->intra_presence_score = presence_result->intra_presence_score;
589 cargo_result->calibration_needed = presence_result->processing_result.calibration_needed;
590
591 if (handle->state.num_presence_process_since_filter_reset >= handle->parameters.num_frames_presence_uses_same_filter)
592 {
593 acc_detector_presence_reset_filters(handle->presence_handle);
594 handle->state.num_presence_process_since_filter_reset = 0U;
595 }
596
597 if (handle->state.num_presence_process_since_prepare >= handle->parameters.num_frames_presence_occupies_cargo_app)
598 {
599 handle->state.current_mode = CARGO_MODE_NONE;
600 }
601 }
602 }
603 break;
604 case CARGO_MODE_UTILIZATION:
605 ACC_LOG_ERROR("Handle is in utilization-mode. Call cargo_process_utilization() instead");
606 status = false;
607 break;
608 case CARGO_MODE_NONE:
609 ACC_LOG_ERROR("cargo_prepare_presence() have not been called beforehand");
610 status = false;
611 break;
612 default:
613 ACC_LOG_ERROR("Unknown current mode");
614 status = false;
615 break;
616 }
617 }
618
619 return status;
620 }
621
622 cargo_mode_t cargo_current_mode_get(const cargo_handle_t *handle)
623 {
624 cargo_mode_t res = CARGO_MODE_NONE;
625
626 if (handle != NULL)
627 {
628 res = handle->state.current_mode;
629 }
630
631 return res;
632 }
633
634 bool cargo_presence_metadata_get(cargo_handle_t *handle, acc_detector_presence_metadata_t *presence_metadata)
635 {
636 bool status = (handle != NULL) && (presence_metadata != NULL);
637
638 if (status)
639 {
640 status = handle->presence_handle != NULL;
641 }
642
643 if (status)
644 {
645 *presence_metadata = handle->presence_metadata;
646 }
647
648 return status;
649 }
650
651 //-----------------------------
652 // Private definitions
653 //-----------------------------
654
655 static bool validate_cargo_config(const cargo_config_t *cargo_config)
656 {
657 bool status = true;
658
659 if (cargo_config == NULL)
660 {
661 ACC_LOG_ERROR("Cargo config is NULL");
662 status = false;
663 }
664
665 if (status && (cargo_config->magic != CARGO_CONFIG_MAGIC))
666 {
667 ACC_LOG_ERROR("Cargo config has not been initialized");
668 status = false;
669 }
670
671 if (status && cargo_config->activate_presence)
672 {
673
674 if (status && (cargo_config->presence.update_rate < CARGO_PRESENCE_MIN_UPDATE_RATE))
675 {
676 ACC_LOG_ERROR("Presence update_rate is too low.");
677 status = false;
678 }
679
680 if (status && (cargo_config->presence.sweeps_per_frame < CARGO_PRESENCE_MIN_SWEEPS_PER_FRAME))
681 {
682 ACC_LOG_ERROR("Presence sweeps_per_frame is too low.");
683 status = false;
684 }
685 }
686
687 if (status && (!cargo_config->activate_utilization_level && !cargo_config->activate_presence))
688 {
689 ACC_LOG_ERROR("Need to activate at least utilization or presence");
690 status = false;
691 }
692
693 return status;
694 }
695
696 static bool populate_handle_with_distance_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
697 {
698 bool status = true;
699
700 if (status)
701 {
702 cargo_handle->distance_config = acc_detector_distance_config_create();
703 status = cargo_handle->distance_config != NULL;
704 }
705
706 if (status)
707 {
708 status = translate_cargo_config_to_distance_config(cargo_config, cargo_handle->distance_config);
709 }
710
711 if (status)
712 {
713 cargo_handle->distance_handle = acc_detector_distance_create(cargo_handle->distance_config);
714 status = cargo_handle->distance_handle != NULL;
715 }
716
717 return status;
718 }
719
720 static bool populate_handle_with_presence_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
721 {
722 bool status = true;
723
724 if (status)
725 {
726 cargo_handle->presence_config = acc_detector_presence_config_create();
727 status = cargo_handle->presence_config != NULL;
728 }
729
730 if (status)
731 {
732 status = translate_cargo_config_to_presence_config(cargo_config, cargo_handle->presence_config);
733 }
734
735 if (status)
736 {
737 cargo_handle->presence_handle = acc_detector_presence_create(cargo_handle->presence_config, &cargo_handle->presence_metadata);
738 status = cargo_handle->presence_handle != NULL;
739 }
740
741 return status;
742 }
743
744 static bool translate_cargo_config_to_distance_config(const cargo_config_t *cargo_config, acc_detector_distance_config_t *distance_config)
745 {
746 bool status = true;
747
748 const float start_m = 0.3;
749 float end_m;
750
751 switch (cargo_config->container_size)
752 {
753 case CARGO_CONTAINER_SIZE_10_FT:
754 end_m = 3.5;
755 break;
756 case CARGO_CONTAINER_SIZE_20_FT:
757 end_m = 6.5;
758 break;
759 case CARGO_CONTAINER_SIZE_40_FT:
760 end_m = 12.5;
761 break;
762 default:
763 ACC_LOG_ERROR("Unexpected container size in config");
764 status = false;
765 }
766
767 if (status)
768 {
769 acc_detector_distance_config_start_set(distance_config, start_m);
770 acc_detector_distance_config_end_set(distance_config, end_m);
771
772 acc_detector_distance_config_signal_quality_set(distance_config, cargo_config->utilization.signal_quality);
773 acc_detector_distance_config_threshold_sensitivity_set(distance_config, cargo_config->utilization.threshold_sensitivity);
774 acc_detector_distance_config_reflector_shape_set(distance_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR);
775 }
776
777 return status;
778 }
779
780 static bool translate_cargo_config_to_presence_config(const cargo_config_t *cargo_config, acc_detector_presence_config_t *presence_config)
781 {
782 bool status = true;
783
784 const float start_m = 0.8f;
785 float end_m;
786
787 switch (cargo_config->container_size)
788 {
789 case CARGO_CONTAINER_SIZE_10_FT:
790 end_m = 2.7;
791 break;
792 case CARGO_CONTAINER_SIZE_20_FT:
793 end_m = 5.7;
794 break;
795 case CARGO_CONTAINER_SIZE_40_FT:
796 end_m = 7.0;
797 break;
798 default:
799 ACC_LOG_ERROR("Unexpected container size in config");
800 status = false;
801 }
802
803 if (status)
804 {
805 acc_detector_presence_config_start_set(presence_config, start_m);
806 acc_detector_presence_config_end_set(presence_config, end_m);
807
808 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, cargo_config->presence.rate_is_app_driven);
809
810 acc_detector_presence_config_intra_detection_threshold_set(presence_config, cargo_config->presence.intra_detection_threshold);
811 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
812 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.30f);
813 acc_detector_presence_config_inter_detection_threshold_set(presence_config, cargo_config->presence.inter_detection_threshold);
814 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
815 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, cargo_config->presence.update_rate);
816 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.50f);
817 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.00f);
818 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 0U); // No timeout
819
820 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
821 acc_detector_presence_config_sweeps_per_frame_set(presence_config, cargo_config->presence.sweeps_per_frame);
822 acc_detector_presence_config_signal_quality_set(presence_config, cargo_config->presence.signal_quality);
823
824 acc_detector_presence_config_frame_rate_set(presence_config, cargo_config->presence.update_rate);
825 }
826
827 return status;
828 }
829
830 static uint16_t presence_calc_num_frames_per_burst(const cargo_config_t *cargo_config)
831 {
832 // "+0.5f" will round (instead of truncate) when casting to uint16_t
833 float num_frames_per_burst_f = (CARGO_PRESENCE_RUN_TIME_S * cargo_config->presence.update_rate) + 0.5f;
834 return (uint16_t)num_frames_per_burst_f;
835 }
836
837 static float float_clip(float value, float min, float max)
838 {
839 float res;
840
841 if (value < min)
842 {
843 res = min;
844 }
845 else if (value > max)
846 {
847 res = max;
848 }
849 else
850 {
851 res = value;
852 }
853
854 return res;
855 }
acc_detector_presence_result_t::inter_presence_score
float inter_presence_score
Definition: acc_detector_presence.h:59
cargo_preset_t
cargo_preset_t
Cargo Example App Presets.
Definition: example_cargo.h:22
acc_integration_mem_calloc
void * acc_integration_mem_calloc(size_t nmemb, size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:597
cargo_handle::num_distance_process_since_prepare
uint16_t num_distance_process_since_prepare
Definition: example_cargo.c:52
acc_detector_distance_result_t::processing_result
acc_processing_result_t * processing_result
Definition: acc_detector_distance.h:105
acc_detector_presence_config_sweeps_per_frame_set
void acc_detector_presence_config_sweeps_per_frame_set(acc_detector_presence_config_t *presence_config, uint16_t sweeps_per_frame)
Set the number of sweeps per frame.
acc_detector_distance_get_sizes
bool acc_detector_distance_get_sizes(const acc_detector_distance_handle_t *handle, uint32_t *buffer_size, uint32_t *detector_cal_result_static_size)
Get the memory size needed to use the Distance Detector API functions.
cargo_config_t::update_rate
float update_rate
Definition: example_cargo.h:75
cargo_result_t::calibration_needed
bool calibration_needed
Definition: example_cargo.h:112
cargo_prepare_utilization
bool cargo_prepare_utilization(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare Cargo utilization for measurements.
Definition: example_cargo.c:384
acc_detector_presence_destroy
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle)
Destroy a presence detector identified with the provided handle.
distance_cal_result_static_size
uint32_t distance_cal_result_static_size
Definition: i2c_example_cargo.c:39
cargo_handle::num_frames_presence_occupies_cargo_app
uint16_t num_frames_presence_occupies_cargo_app
Definition: example_cargo.c:42
CARGO_MODE_UTILIZATION
@ CARGO_MODE_UTILIZATION
Definition: example_cargo.h:156
cargo_config_t::intra_detection_threshold
float intra_detection_threshold
Definition: example_cargo.h:96
ACC_LOG_INFO
#define ACC_LOG_INFO(...)
Definition: acc_integration_log.h:18
buffer
void * buffer
Definition: i2c_example_cargo.c:40
acc_detector_presence_config_inter_frame_deviation_time_const_set
void acc_detector_presence_config_inter_frame_deviation_time_const_set(acc_detector_presence_config_t *presence_config, float inter_frame_deviation_time_const)
Set the time constant of the low pass filter for the inter-frame deviation between fast and slow.
cargo_mode_t
cargo_mode_t
Cargo mode enumeration.
Definition: example_cargo.h:153
sensor_cal_result
acc_cal_result_t sensor_cal_result
Definition: i2c_example_cargo.c:36
cargo_config_t::signal_quality
float signal_quality
Definition: example_cargo.h:57
cargo_prepare_presence
bool cargo_prepare_presence(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare Cargo presence for measurements.
Definition: example_cargo.c:423
cargo_get_distance_cal_result_static_size
bool cargo_get_distance_cal_result_static_size(const cargo_handle_t *handle, uint32_t *distance_cal_result_static_size)
Get the required buffer for static distance detector calibration.
Definition: example_cargo.c:298
acc_detector_presence_result_t::processing_result
acc_processing_result_t processing_result
Definition: acc_detector_presence.h:82
cargo_result_t::distance
float distance
Definition: example_cargo.h:118
CARGO_PRESENCE_MIN_SWEEPS_PER_FRAME
#define CARGO_PRESENCE_MIN_SWEEPS_PER_FRAME
Definition: example_cargo.c:22
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
distance_cal_result_static
uint8_t * distance_cal_result_static
Definition: i2c_example_cargo.c:38
acc_detector_distance_config_start_set
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set start of measured interval (m)
acc_detector_presence_config_frame_rate_set
void acc_detector_presence_config_frame_rate_set(acc_detector_presence_config_t *presence_config, float frame_rate)
Set the frame rate.
cargo_handle::parameters
struct cargo_handle::@5 parameters
cargo_config_t::magic
uint32_t magic
Definition: example_cargo.h:45
cargo_result_t::level_m
float level_m
Definition: example_cargo.h:123
cargo_container_size_t
cargo_container_size_t
Container size.
Definition: example_cargo.h:33
cargo_config_t::utilization
struct cargo_config_t::@0 utilization
populate_handle_with_distance_resources
static bool populate_handle_with_distance_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
Definition: example_cargo.c:696
validate_cargo_config
static bool validate_cargo_config(const cargo_config_t *cargo_config)
Definition: example_cargo.c:655
acc_integration.h
ACC_LOG_ERROR
#define ACC_LOG_ERROR(...)
Definition: acc_integration_log.h:16
acc_detector_presence_get_buffer_size
bool acc_detector_presence_get_buffer_size(const acc_detector_presence_handle_t *presence_handle, uint32_t *buffer_size)
Get the buffer size needed for the provided presence detector handle.
acc_detector_distance_result_t::num_distances
uint8_t num_distances
Definition: acc_detector_distance.h:70
acc_detector_distance_create
acc_detector_distance_handle_t * acc_detector_distance_create(const acc_detector_distance_config_t *config)
Create Distance Detector handle using the provided Distance Detector configuration.
presence_calc_num_frames_per_burst
static uint16_t presence_calc_num_frames_per_burst(const cargo_config_t *cargo_config)
Definition: example_cargo.c:830
cargo_config_t
Configuration struct for cargo.
Definition: example_cargo.h:43
acc_detector_distance_config_destroy
void acc_detector_distance_config_destroy(acc_detector_distance_config_t *config)
Destroy Distance Detector configuration.
cargo_result_t::inter_presence_score
float inter_presence_score
Definition: example_cargo.h:137
acc_detector_presence_result_t::presence_detected
bool presence_detected
Definition: acc_detector_presence.h:51
acc_detector_presence_config_intra_detection_threshold_set
void acc_detector_presence_config_intra_detection_threshold_set(acc_detector_presence_config_t *presence_config, float intra_detection_threshold)
Set the detection threshold for the intra-frame presence detection.
acc_detector_distance_calibrate
bool acc_detector_distance_calibrate(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, uint8_t *detector_cal_result_static, uint32_t detector_cal_result_static_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Calibrate detector.
cargo_result_t::level_percent
float level_percent
Definition: example_cargo.h:128
acc_detector_distance_process
bool acc_detector_distance_process(acc_detector_distance_handle_t *handle, void *buffer, uint8_t *detector_cal_result_static, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *result_available, acc_detector_distance_result_t *result)
Process sensor data into a Detector result.
cargo_config_t::sweeps_per_frame
uint16_t sweeps_per_frame
Definition: example_cargo.h:80
CARGO_CONTAINER_SIZE_10_FT
@ CARGO_CONTAINER_SIZE_10_FT
Definition: example_cargo.h:35
acc_sensor.h
acc_detector_presence_result_t
Presence detector results container.
Definition: acc_detector_presence.h:46
buffer_size
uint32_t buffer_size
Definition: i2c_example_cargo.c:41
CARGO_MODE_NONE
@ CARGO_MODE_NONE
Definition: example_cargo.h:155
acc_detector_cal_result_dynamic_t
The result from a completed calibration update.
Definition: acc_detector_distance_definitions.h:23
acc_detector_presence_config_inter_frame_presence_timeout_set
void acc_detector_presence_config_inter_frame_presence_timeout_set(acc_detector_presence_config_t *presence_config, uint16_t inter_frame_presence_timeout)
Set the inter-frame presence timeout in seconds.
ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
Definition: acc_detector_distance_definitions.h:62
cargo_config_t::rate_is_app_driven
bool rate_is_app_driven
Definition: example_cargo.h:102
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
cargo_current_mode_get
cargo_mode_t cargo_current_mode_get(const cargo_handle_t *handle)
Get current mode of the cargo handle.
Definition: example_cargo.c:622
CARGO_CONTAINER_SIZE_40_FT
@ CARGO_CONTAINER_SIZE_40_FT
Definition: example_cargo.h:37
example_cargo.h
acc_detector_presence_config_destroy
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
acc_detector_presence_metadata_t
Definition: acc_detector_presence.h:88
acc_detector_distance_destroy
void acc_detector_distance_destroy(acc_detector_distance_handle_t *handle)
Destroy Distance Detector handle, freeing its resources.
cargo_result_t::utilization_valid
bool utilization_valid
Definition: example_cargo.h:115
cargo_handle::num_frames_presence_uses_same_filter
uint16_t num_frames_presence_uses_same_filter
Definition: example_cargo.c:43
cargo_config_log
void cargo_config_log(const cargo_config_t *cargo_config)
Log cargo config to debug uart.
Definition: example_cargo.c:135
acc_detector_presence_config_end_set
void acc_detector_presence_config_end_set(acc_detector_presence_config_t *presence_config, float end)
Set the end point of measurement interval in meters.
acc_detector_presence_config_intra_output_time_const_set
void acc_detector_presence_config_intra_output_time_const_set(acc_detector_presence_config_t *presence_config, float intra_output_time_const)
Set the time constant for the output in the intra-frame part.
acc_detector_distance_config_signal_quality_set
void acc_detector_distance_config_signal_quality_set(acc_detector_distance_config_t *config, float signal_quality)
Set signal quality (dB)
handle
cargo_handle_t * handle
Definition: i2c_example_cargo.c:35
cargo_handle_destroy
void cargo_handle_destroy(cargo_handle_t *handle)
Destroy a cargo handle.
Definition: example_cargo.c:240
cargo_result_t::presence_valid
bool presence_valid
Definition: example_cargo.h:131
cargo_handle::distance_config
acc_detector_distance_config_t * distance_config
Definition: example_cargo.c:29
cargo_handle::num_presence_process_since_prepare
uint16_t num_presence_process_since_prepare
Definition: example_cargo.c:53
cargo_config_t::presence
struct cargo_config_t::@1 presence
acc_detector_presence_result_t::intra_presence_score
float intra_presence_score
Definition: acc_detector_presence.h:55
cargo_handle::container_size
cargo_container_size_t container_size
Definition: example_cargo.c:39
CARGO_CONTAINER_SIZE_20_FT
@ CARGO_CONTAINER_SIZE_20_FT
Definition: example_cargo.h:36
acc_detector_presence_process
bool acc_detector_presence_process(acc_detector_presence_handle_t *presence_handle, void *buffer, acc_detector_presence_result_t *result)
Process the data according to the configuration used in acc_detector_presence_config_create.
acc_detector_presence_config_inter_output_time_const_set
void acc_detector_presence_config_inter_output_time_const_set(acc_detector_presence_config_t *presence_config, float inter_output_time_const)
Set the time constant for the output in the inter-frame part.
CARGO_PRESENCE_MIN_UPDATE_RATE
#define CARGO_PRESENCE_MIN_UPDATE_RATE
Definition: example_cargo.c:21
cargo_calibrate
bool cargo_calibrate(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, uint8_t *distance_cal_result_static, uint32_t distance_cal_result_static_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
Calibrate Cargo.
Definition: example_cargo.c:318
cargo_handle::presence_handle
acc_detector_presence_handle_t * presence_handle
Definition: example_cargo.c:33
cargo_presence_metadata_get
bool cargo_presence_metadata_get(cargo_handle_t *handle, acc_detector_presence_metadata_t *presence_metadata)
Get presence detector metadata.
Definition: example_cargo.c:634
CARGO_PRESET_CONTAINER_40_FEET
@ CARGO_PRESET_CONTAINER_40_FEET
Definition: example_cargo.h:26
acc_detector_distance_prepare
bool acc_detector_distance_prepare(const acc_detector_distance_handle_t *handle, const acc_detector_distance_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the Detector for measurements.
cargo_config_t::activate_utilization_level
bool activate_utilization_level
Definition: example_cargo.h:49
acc_detector_distance_result_t
Distance Detector result returned from acc_detector_distance_process.
Definition: acc_detector_distance.h:48
acc_detector_presence_prepare
bool acc_detector_presence_prepare(const acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, const acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Prepare the detector to do a measurement.
cargo_handle::num_frames_distance_occupies_cargo_app
uint16_t num_frames_distance_occupies_cargo_app
Definition: example_cargo.c:41
populate_handle_with_presence_resources
static bool populate_handle_with_presence_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
Definition: example_cargo.c:720
cargo_result_t::intra_presence_score
float intra_presence_score
Definition: example_cargo.h:140
cargo_handle_create
cargo_handle_t * cargo_handle_create(const cargo_config_t *cargo_config)
Create a cargo handle.
Definition: example_cargo.c:164
CARGO_PRESET_CONTAINER_10_FEET
@ CARGO_PRESET_CONTAINER_10_FEET
Definition: example_cargo.h:24
cargo_handle::presence_config
acc_detector_presence_config_t * presence_config
Definition: example_cargo.c:32
acc_detector_presence_config_t
struct acc_detector_presence_config acc_detector_presence_config_t
Definition: acc_detector_presence.h:41
acc_detector_distance_config_end_set
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set end of measured interval (m)
translate_cargo_config_to_presence_config
static bool translate_cargo_config_to_presence_config(const cargo_config_t *cargo_config, acc_detector_presence_config_t *presence_config)
Definition: example_cargo.c:780
cargo_handle::current_mode
cargo_mode_t current_mode
Definition: example_cargo.c:50
acc_integration_log.h
acc_detector_presence_config_inter_frame_slow_cutoff_set
void acc_detector_presence_config_inter_frame_slow_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_slow_cutoff)
Set the cutoff frequency of the low pass filter for the slow filtered absolute sweep mean.
acc_detector_distance_handle_t
struct acc_detector_distance_handle acc_detector_distance_handle_t
Distance Detector handle.
Definition: acc_detector_distance.h:36
cargo_config_initialize
void cargo_config_initialize(cargo_config_t *cargo_config, cargo_preset_t preset)
Initialize cargo config struct with a preset.
Definition: example_cargo.c:80
ACC_LOG_FLOAT_TO_INTEGER
#define ACC_LOG_FLOAT_TO_INTEGER(a)
Definition: acc_integration_log.h:26
cargo_handle::presence_metadata
acc_detector_presence_metadata_t presence_metadata
Definition: example_cargo.c:34
float_clip
static float float_clip(float value, float min, float max)
Definition: example_cargo.c:837
acc_detector_presence_reset_filters
void acc_detector_presence_reset_filters(const acc_detector_presence_handle_t *presence_handle)
Reset internal filters.
acc_detector_distance_update_calibration
bool acc_detector_distance_update_calibration(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Perform a subset of the full Detector calibration.
CARGO_CONFIG_MAGIC
#define CARGO_CONFIG_MAGIC
Definition: example_cargo.c:19
cargo_handle::num_presence_process_since_filter_reset
uint16_t num_presence_process_since_filter_reset
Definition: example_cargo.c:54
cargo_update_calibration
bool cargo_update_calibration(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
Update Cargo calibration.
Definition: example_cargo.c:353
cargo_handle::distance_handle
acc_detector_distance_handle_t * distance_handle
Definition: example_cargo.c:30
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_stm32.c:602
cargo_config_t::container_size
cargo_container_size_t container_size
Definition: example_cargo.h:47
acc_detector_distance_config_reflector_shape_set
void acc_detector_distance_config_reflector_shape_set(acc_detector_distance_config_t *config, acc_detector_distance_reflector_shape_t reflector_shape)
Set reflector shape.
cargo_get_buffer_size
bool cargo_get_buffer_size(const cargo_handle_t *handle, uint32_t *buffer_size)
Get the required buffer sensor data buffer size.
Definition: example_cargo.c:272
acc_detector_presence_create
acc_detector_presence_handle_t * acc_detector_presence_create(acc_detector_presence_config_t *presence_config, acc_detector_presence_metadata_t *metadata)
Create a presence detector with the provided configuration.
CARGO_PRESET_CONTAINER_20_FEET
@ CARGO_PRESET_CONTAINER_20_FEET
Definition: example_cargo.h:25
acc_detector_distance_config_threshold_sensitivity_set
void acc_detector_distance_config_threshold_sensitivity_set(acc_detector_distance_config_t *config, float threshold_sensitivity)
Set threshold sensitivity.
acc_detector_distance_config_create
acc_detector_distance_config_t * acc_detector_distance_config_create(void)
Create a Distance Detector configuration.
acc_config.h
distance_cal_result_dynamic
acc_detector_cal_result_dynamic_t distance_cal_result_dynamic
Definition: i2c_example_cargo.c:37
cargo_process_presence
bool cargo_process_presence(cargo_handle_t *handle, void *buffer, cargo_result_t *cargo_result, acc_detector_presence_result_t *nullable_presence_result)
Process Sparse IQ data into a Cargo result.
Definition: example_cargo.c:558
acc_detector_distance_result_t::distances
float distances[(10U)]
Definition: acc_detector_distance.h:55
acc_detector_presence_handle_t
struct acc_detector_presence_handle acc_detector_presence_handle_t
Definition: acc_detector_presence.h:34
CARGO_PRESENCE_RUN_TIME_S
#define CARGO_PRESENCE_RUN_TIME_S
Definition: example_cargo.c:20
acc_detector_distance.h
cargo_handle
Cargo handle.
Definition: example_cargo.c:27
acc_detector_presence_config_create
acc_detector_presence_config_t * acc_detector_presence_config_create(void)
Create a configuration for a presence detector.
PRIfloat
#define PRIfloat
Specifier for printing float type using integers.
Definition: acc_integration_log.h:31
cargo_result_t
Result type.
Definition: example_cargo.h:109
cargo_result_t::presence_detected
bool presence_detected
Definition: example_cargo.h:134
acc_detector_presence_config_signal_quality_set
void acc_detector_presence_config_signal_quality_set(acc_detector_presence_config_t *presence_config, float signal_quality)
Set signal quality.
acc_detector_presence_config_start_set
void acc_detector_presence_config_start_set(acc_detector_presence_config_t *presence_config, float start)
Set the start point of measurement interval in meters.
cargo_process_utilization
bool cargo_process_utilization(cargo_handle_t *handle, uint8_t *distance_cal_result_static, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, void *buffer, cargo_result_t *cargo_result, bool *result_available, acc_detector_distance_result_t *nullable_distance_result)
Process Sparse IQ data into a Cargo result.
Definition: example_cargo.c:462
acc_processing_result_t::calibration_needed
bool calibration_needed
Definition: acc_processing.h:84
acc_detector_distance_config_t
struct acc_detector_distance_config acc_detector_distance_config_t
Distance Detector configuration.
Definition: acc_detector_distance.h:43
acc_detector_presence.h
CARGO_PRESET_NO_LENS
@ CARGO_PRESET_NO_LENS
Definition: example_cargo.h:27
cargo_handle::state
struct cargo_handle::@6 state
acc_detector_presence_config_inter_detection_threshold_set
void acc_detector_presence_config_inter_detection_threshold_set(acc_detector_presence_config_t *presence_config, float inter_detection_threshold)
Set the detection threshold for the inter-frame presence detection.
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
cargo_config_t::inter_detection_threshold
float inter_detection_threshold
Definition: example_cargo.h:91
cargo_config_t::threshold_sensitivity
float threshold_sensitivity
Definition: example_cargo.h:65
acc_detector_presence_config_intra_frame_time_const_set
void acc_detector_presence_config_intra_frame_time_const_set(acc_detector_presence_config_t *presence_config, float intra_frame_time_const)
Set the time constant for the depthwise filtering in the intra-frame part.
acc_detector_presence_config_automatic_subsweeps_set
void acc_detector_presence_config_automatic_subsweeps_set(acc_detector_presence_config_t *presence_config, bool automatic_subsweeps)
Set if automatic subsweeps should be used.
cargo_config_t::activate_presence
bool activate_presence
Definition: example_cargo.h:68
CARGO_MODE_PRESENCE
@ CARGO_MODE_PRESENCE
Definition: example_cargo.h:157
acc_detector_presence_config_frame_rate_app_driven_set
void acc_detector_presence_config_frame_rate_app_driven_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the application should maintain the requested frame rate.
translate_cargo_config_to_distance_config
static bool translate_cargo_config_to_distance_config(const cargo_config_t *cargo_config, acc_detector_distance_config_t *distance_config)
Definition: example_cargo.c:744
acc_detector_presence_config_inter_frame_fast_cutoff_set
void acc_detector_presence_config_inter_frame_fast_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_fast_cutoff)
Set the cutoff frequency of the low pass filter for the fast filtered absolute sweep mean.