Go to the documentation of this file.
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
74 static float float_clip(
float value,
float min,
float max);
82 bool status = cargo_config != NULL;
140 ACC_LOG_INFO(
"container_size: CARGO_CONTAINER_SIZE_10_FT");
143 ACC_LOG_INFO(
"container_size: CARGO_CONTAINER_SIZE_20_FT");
146 ACC_LOG_INFO(
"container_size: CARGO_CONTAINER_SIZE_40_FT");
237 return status ?
handle : NULL;
277 uint32_t distance_buffer_size = 0U;
278 uint32_t presence_buffer_size = 0U;
292 *
buffer_size = distance_buffer_size > presence_buffer_size ? distance_buffer_size : presence_buffer_size;
326 bool *calibration_complete)
328 bool status = (
handle != NULL) && (calibration_complete != NULL);
334 *calibration_complete =
true;
346 calibration_complete);
359 bool *calibration_complete)
361 bool status = (
handle != NULL) && (calibration_complete != NULL);
367 *calibration_complete =
true;
377 calibration_complete);
390 bool status = (
handle != NULL);
406 ACC_LOG_ERROR(
"Handle is currently in presence-mode. More calls to cargo_process_presence() is expected");
410 ACC_LOG_ERROR(
"Handle has already prepared for utilization level measurement. More calls to cargo_process_utilization() is expected");
429 bool status = (
handle != NULL);
445 ACC_LOG_ERROR(
"Handle has already prepared for presence measurement. More calls to cargo_process_utilization() is expected");
449 ACC_LOG_ERROR(
"Handle is currently in utilization-mode. More calls to cargo_process_utilization() is expected");
467 bool *result_available,
470 bool distance_result_available =
false;
475 bool status = (
handle != NULL) && (cargo_result != NULL) && (result_available != NULL);
490 &distance_result_available,
495 *result_available = distance_result_available;
499 float distance_m = distance_result->
distances[0];
501 float container_size_length_m = 0.0f;
505 container_size_length_m = 3.0f;
508 container_size_length_m = 6.0f;
511 container_size_length_m = 12.0f;
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);
541 ACC_LOG_ERROR(
"Handle is in presence-mode. Call cargo_process_presence() instead");
545 ACC_LOG_ERROR(
"cargo_prepare_utilization() have not been called beforehand");
567 bool status = (
handle != NULL) && (cargo_result != NULL);
605 ACC_LOG_ERROR(
"Handle is in utilization-mode. Call cargo_process_utilization() instead");
609 ACC_LOG_ERROR(
"cargo_prepare_presence() have not been called beforehand");
636 bool status = (
handle != NULL) && (presence_metadata != NULL);
659 if (cargo_config == NULL)
689 ACC_LOG_ERROR(
"Need to activate at least utilization or presence");
748 const float start_m = 0.3;
784 const float start_m = 0.8f;
834 return (uint16_t)num_frames_per_burst_f;
845 else if (value > max)
float inter_presence_score
cargo_preset_t
Cargo Example App Presets.
void * acc_integration_mem_calloc(size_t nmemb, size_t size)
Allocate dynamic memory.
uint16_t num_distance_process_since_prepare
acc_processing_result_t * processing_result
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.
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.
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.
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle)
Destroy a presence detector identified with the provided handle.
uint32_t distance_cal_result_static_size
uint16_t num_frames_presence_occupies_cargo_app
float intra_detection_threshold
#define ACC_LOG_INFO(...)
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 enumeration.
acc_cal_result_t sensor_cal_result
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.
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.
acc_processing_result_t processing_result
#define CARGO_PRESENCE_MIN_SWEEPS_PER_FRAME
The result from a completed calibration.
uint8_t * distance_cal_result_static
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set start of measured interval (m)
void acc_detector_presence_config_frame_rate_set(acc_detector_presence_config_t *presence_config, float frame_rate)
Set the frame rate.
struct cargo_handle::@5 parameters
cargo_container_size_t
Container size.
struct cargo_config_t::@0 utilization
static bool populate_handle_with_distance_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
static bool validate_cargo_config(const cargo_config_t *cargo_config)
#define ACC_LOG_ERROR(...)
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_handle_t * acc_detector_distance_create(const acc_detector_distance_config_t *config)
Create Distance Detector handle using the provided Distance Detector configuration.
static uint16_t presence_calc_num_frames_per_burst(const cargo_config_t *cargo_config)
Configuration struct for cargo.
void acc_detector_distance_config_destroy(acc_detector_distance_config_t *config)
Destroy Distance Detector configuration.
float inter_presence_score
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.
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.
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.
uint16_t sweeps_per_frame
@ CARGO_CONTAINER_SIZE_10_FT
Presence detector results container.
The result from a completed calibration update.
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
cargo_mode_t cargo_current_mode_get(const cargo_handle_t *handle)
Get current mode of the cargo handle.
@ CARGO_CONTAINER_SIZE_40_FT
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
void acc_detector_distance_destroy(acc_detector_distance_handle_t *handle)
Destroy Distance Detector handle, freeing its resources.
uint16_t num_frames_presence_uses_same_filter
void cargo_config_log(const cargo_config_t *cargo_config)
Log cargo config to debug uart.
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.
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.
void acc_detector_distance_config_signal_quality_set(acc_detector_distance_config_t *config, float signal_quality)
Set signal quality (dB)
void cargo_handle_destroy(cargo_handle_t *handle)
Destroy a cargo handle.
acc_detector_distance_config_t * distance_config
uint16_t num_presence_process_since_prepare
struct cargo_config_t::@1 presence
float intra_presence_score
cargo_container_size_t container_size
@ CARGO_CONTAINER_SIZE_20_FT
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.
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.
#define CARGO_PRESENCE_MIN_UPDATE_RATE
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.
acc_detector_presence_handle_t * presence_handle
bool cargo_presence_metadata_get(cargo_handle_t *handle, acc_detector_presence_metadata_t *presence_metadata)
Get presence detector metadata.
@ CARGO_PRESET_CONTAINER_40_FEET
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.
bool activate_utilization_level
Distance Detector result returned from acc_detector_distance_process.
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.
uint16_t num_frames_distance_occupies_cargo_app
static bool populate_handle_with_presence_resources(const cargo_config_t *cargo_config, cargo_handle_t *cargo_handle)
float intra_presence_score
cargo_handle_t * cargo_handle_create(const cargo_config_t *cargo_config)
Create a cargo handle.
@ CARGO_PRESET_CONTAINER_10_FEET
acc_detector_presence_config_t * presence_config
struct acc_detector_presence_config acc_detector_presence_config_t
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set end of measured interval (m)
static bool translate_cargo_config_to_presence_config(const cargo_config_t *cargo_config, acc_detector_presence_config_t *presence_config)
cargo_mode_t current_mode
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.
struct acc_detector_distance_handle acc_detector_distance_handle_t
Distance Detector handle.
void cargo_config_initialize(cargo_config_t *cargo_config, cargo_preset_t preset)
Initialize cargo config struct with a preset.
#define ACC_LOG_FLOAT_TO_INTEGER(a)
acc_detector_presence_metadata_t presence_metadata
static float float_clip(float value, float min, float max)
void acc_detector_presence_reset_filters(const acc_detector_presence_handle_t *presence_handle)
Reset internal filters.
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.
#define CARGO_CONFIG_MAGIC
uint16_t num_presence_process_since_filter_reset
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.
acc_detector_distance_handle_t * distance_handle
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
cargo_container_size_t container_size
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.
bool cargo_get_buffer_size(const cargo_handle_t *handle, uint32_t *buffer_size)
Get the required buffer sensor data buffer size.
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
void acc_detector_distance_config_threshold_sensitivity_set(acc_detector_distance_config_t *config, float threshold_sensitivity)
Set threshold sensitivity.
acc_detector_distance_config_t * acc_detector_distance_config_create(void)
Create a Distance Detector configuration.
acc_detector_cal_result_dynamic_t distance_cal_result_dynamic
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.
struct acc_detector_presence_handle acc_detector_presence_handle_t
#define CARGO_PRESENCE_RUN_TIME_S
acc_detector_presence_config_t * acc_detector_presence_config_create(void)
Create a configuration for a presence detector.
#define PRIfloat
Specifier for printing float type using integers.
void acc_detector_presence_config_signal_quality_set(acc_detector_presence_config_t *presence_config, float signal_quality)
Set signal quality.
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.
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.
struct acc_detector_distance_config acc_detector_distance_config_t
Distance Detector configuration.
struct cargo_handle::@6 state
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.
struct acc_sensor acc_sensor_t
float inter_detection_threshold
float threshold_sensitivity
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.
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.
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.
static bool translate_cargo_config_to_distance_config(const cargo_config_t *cargo_config, acc_detector_distance_config_t *distance_config)
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.