example_processing_peak_interpolation.c This program shows how to apply a distance filter and how to interpolate the position of the peak to improve distance accuracy.The distance filter is applied to the IQ data and will reduce noise and smooth out the the amplitude of the radar eacho peaks. The smoothing is important for the next step where we estimate the acctual position of the peak, i.e the position of the peak that we would have gotten if we had used an shorter distance between the measurement steps.
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#define SENSOR_ID (1U)
{
(void)argc;
(void)argv;
const uint32_t peak_width_points = 104;
{
return EXIT_FAILURE;
}
if (!status_ok)
{
printf("acc_control_helper_create ()failed \n");
return EXIT_FAILURE;
}
if (!status_ok)
{
printf("acc_control_helper_activate ()failed\n");
return EXIT_FAILURE;
}
bool mem_ok = (current_sweep_iq != NULL) && (filtered_sweep_iq != NULL) &&
(filter_vector != NULL) && (filtered_sweep_amplitude != NULL);
if (!mem_ok)
{
printf("Memory allocation for vectors failed\n");
goto clean_up;
}
uint32_t iterations = 50U;
for (uint32_t i = 0U; i < iterations; i++)
{
{
printf("acc_control_helper_get_next() failed\n");
break;
}
filtered_sweep_amplitude->
data[max_peak_index],
filtered_sweep_amplitude->
data[max_peak_index + 1]);
float distance = start + (max_peak_index + peak_offset) * step_length;
printf("Interpolated distance: %d mm\n", (int)(distance * 1000 + .5f));
}
clean_up:
printf("Application finished OK\n");
return EXIT_SUCCESS;
}
{
int32_t start_point = 100;
uint16_t step_length = 8;
uint16_t num_points = 50;
}
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.
uint32_t acc_vector_float_argmax_skip_edges(acc_vector_float_t *vector_a, uint32_t elements_to_skip)
Index of element with maximum value in a float vector disregarding edge elements.
int app_main(int argc, char *argv[])
Assembly test example.
uint32_t acc_processing_helper_get_filter_length(uint32_t peak_width_points, uint32_t step_length)
Calculate filter vector length.
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.
int32_t acc_config_start_point_get(const acc_config_t *config)
Get the starting point of the sweep.
acc_processing_metadata_t proc_meta
void acc_vector_iq_apply_filter(const acc_vector_iq_t *vector_a, acc_vector_float_t *filter_vector, acc_vector_iq_t *vector_out)
Apply a FIR filter to an IQ vector.
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
uint16_t acc_config_step_length_get(const acc_config_t *config)
Get the step length in a sweep.
float acc_processing_points_to_meter(int32_t points)
Convert a distance or step length in points to meter.
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.
void acc_vector_float_create_depth_filter_vector(acc_vector_float_t *vector_out)
Create a distance filter vector.
void acc_config_phase_enhancement_set(acc_config_t *config, bool enable)
Enable or disable phase enhancement.
static void update_configuration(acc_config_t *config)
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.
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.
float acc_processing_helper_interpolate_peak_position(float y1, float y2, float y3)
Interpolate peak position.