example_processing_subtract_adaptive_bg.c This program shows how to estimate background reflections by calculating a coherent exponential average over the incomming radar measurements. As we use IQ data and include the phase information when we do the calculations, it is possible to subtract the background that contains all static - or at least almost static - reflections from the signal. What we have left are the reflections from objects in motion.
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#define SENSOR_ID (1U)
{
(void)argc;
(void)argv;
{
return EXIT_FAILURE;
}
if (!res)
{
printf("acc_control_helper_create() failed\n");
return EXIT_FAILURE;
}
if (!res)
{
printf("acc_control_helper_activate() failed\n");
return EXIT_FAILURE;
}
bool mem_ok = (current_sweep_iq != NULL) && (adaptive_background_iq != NULL) &&
(motion_reflections_iq != NULL) && (adaptive_background_amplitude != NULL) &&
(motion_reflections_amplitude != NULL);
if (!mem_ok)
{
printf("Memory allocation for vectors failed\n");
goto clean_up;
}
float time_constant_static_background = 5.0f;
uint32_t iterations = 50U;
for (uint32_t i = 0U; i < iterations; i++)
{
{
printf("acc_control_helper_get_next() failed\n");
break;
}
printf("Highest background peak index : %" PRIu32 "\n", max_peak_index_static);
printf("Highest motion peak index : %" PRIu32 "\n", max_peak_index_motion);
}
clean_up:
printf("Application finished OK\n");
return EXIT_SUCCESS;
}
{
int32_t start_point = 100;
uint16_t step_length = 12;
uint16_t num_points = 16;
}
void acc_config_start_point_set(acc_config_t *config, int32_t start_point)
Set the starting point of the sweep.
bool acc_control_helper_create(acc_control_helper_t *radar, acc_sensor_id_t sensor_id)
Create a helper instance.
void acc_vector_float_free(acc_vector_float_t *vector)
Free storage of data elements in a float vector.
void acc_vector_iq_free(acc_vector_iq_t *vector)
Free storage of data elements in an IQ vector.
void acc_config_profile_set(acc_config_t *config, acc_config_profile_t profile)
Set a profile.
void acc_config_sweeps_per_frame_set(acc_config_t *config, uint16_t sweeps)
Set sweeps per frame.
float acc_processing_helper_dynamic_sf(float static_sf, uint32_t update_count)
Calculate a dynamic smoothing factor.
void acc_vector_iq_subtract(const acc_vector_iq_t *vector_a, const acc_vector_iq_t *vector_b, acc_vector_iq_t *vector_out)
Subtract two IQ vectors.
void acc_control_helper_destroy(acc_control_helper_t *radar)
Destroy a helper instance.
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
void acc_config_frame_rate_set(acc_config_t *config, float frame_rate)
Set the frame rate.
acc_processing_metadata_t proc_meta
int app_main(int argc, char *argv[])
Assembly test example.
void acc_vector_iq_amplitude(const acc_vector_iq_t *vector_a, acc_vector_float_t *vector_out)
Amplitude of an IQ vector.
void acc_config_hwaas_set(acc_config_t *config, uint16_t hwaas)
Set the hardware accelerated average samples (HWAAS)
const char * acc_version_get(void)
Get the version of the Acconeer software.
struct acc_config acc_config_t
float acc_config_frame_rate_get(const acc_config_t *config)
Get the frame rate.
void acc_config_step_length_set(acc_config_t *config, uint16_t step_length)
Set the step length in a sweep.
void acc_config_num_points_set(acc_config_t *config, uint16_t num_points)
Set the number of data points to measure.
acc_vector_iq_t * acc_vector_iq_alloc(uint32_t data_length)
Allocate storage for an IQ vector.
acc_vector_float_t * acc_vector_float_alloc(uint32_t data_length)
Allocate storage for a float vector.
void acc_vector_float_print(const char *label, acc_vector_float_t *vector_a)
Print float vector.
static const acc_hal_a121_t hal
bool acc_control_helper_activate(acc_control_helper_t *radar)
Activate the sensor.
void acc_config_prf_set(acc_config_t *config, acc_config_prf_t prf)
Set Pulse Repetition Frequency.
@ ACC_CONFIG_PRF_13_0_MHZ
bool acc_control_helper_get_next(acc_control_helper_t *radar)
Perform a radar measurement and wait for the result.
void acc_get_iq_sweep_vector(const acc_control_helper_t *control_helper_state, acc_vector_iq_t *vector_out)
Converts a newly captured IQ frame with one sweep to an IQ vector.
static void update_configuration(acc_config_t *config)
uint32_t acc_vector_float_argmax(acc_vector_float_t *vector_a)
Index of element with maximum value in a float vector.
void acc_vector_iq_update_exponential_average(const acc_vector_iq_t *current, acc_vector_iq_t *averaged_data, float sf)
Update the exponential average of an IQ vector.
float acc_processing_helper_tc_to_sf(float time_constant_s, float update_rate_hz)
Convert time constant to smoothing factor.