acc_processing_helpers.h File Reference
#include <complex.h>
#include <stdbool.h>
#include <stdint.h>
#include "acc_control_helper.h"

Go to the source code of this file.

Data Structures

struct  acc_vector_iq_t
 
struct  acc_vector_float_t
 

Functions

acc_vector_iq_tacc_vector_iq_alloc (uint32_t data_length)
 Allocate storage for an IQ vector. More...
 
acc_vector_float_tacc_vector_float_alloc (uint32_t data_length)
 Allocate storage for a float vector. More...
 
void acc_vector_iq_free (acc_vector_iq_t *vector)
 Free storage of data elements in an IQ vector. More...
 
void acc_vector_float_free (acc_vector_float_t *vector)
 Free storage of data elements in a float vector. More...
 
float acc_processing_helper_tc_to_sf (float time_constant_s, float update_rate_hz)
 Convert time constant to smoothing factor. More...
 
float acc_processing_helper_dynamic_sf (float static_sf, uint32_t update_count)
 Calculate a dynamic smoothing factor. More...
 
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. More...
 
void acc_vector_float_update_exponential_average (const acc_vector_float_t *current, acc_vector_float_t *averaged_data, float sf)
 Update the exponential average of a float vector. More...
 
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. More...
 
void acc_get_iq_point_vector (const acc_control_helper_t *control_helper_state, uint32_t point, acc_vector_iq_t *vector_out)
 Extract an IQ vector with sweep data for a specific point from a newly captured IQ frame with multiple sweeps. More...
 
uint32_t acc_processing_helper_get_filter_length (uint32_t peak_width_points, uint32_t step_length)
 Calculate filter vector length. More...
 
void acc_vector_float_create_depth_filter_vector (acc_vector_float_t *vector_out)
 Create a distance filter vector. More...
 
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. More...
 
void acc_vector_iq_copy (const acc_vector_iq_t *vector_a, acc_vector_iq_t *vector_out)
 Copy an IQ vector. More...
 
void acc_vector_iq_add (const acc_vector_iq_t *vector_a, const acc_vector_iq_t *vector_b, acc_vector_iq_t *vector_out)
 Add two IQ vectors. More...
 
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. More...
 
void acc_vector_iq_mult (const acc_vector_iq_t *vector_a, const acc_vector_iq_t *vector_b, acc_vector_iq_t *vector_out)
 Multiply two IQ vectors. More...
 
void acc_vector_iq_mult_conj (const acc_vector_iq_t *vector_a, const acc_vector_iq_t *vector_b, acc_vector_iq_t *vector_out)
 Multiply first IQ vector with conjugate of second IQ vector. More...
 
void acc_vector_iq_rotate_phase_inline (acc_vector_iq_t *vector_a, float radians)
 Rotate the phase of elements in an IQ vector. More...
 
void acc_vector_iq_conj_inline (acc_vector_iq_t *vector_a)
 Update an IQ vector with its conjugate. More...
 
void acc_vector_iq_amplitude (const acc_vector_iq_t *vector_a, acc_vector_float_t *vector_out)
 Amplitude of an IQ vector. More...
 
float acc_vector_iq_coherent_mean_amplitude (const acc_vector_iq_t *vector_a)
 Coherent mean amplitude of IQ vector. More...
 
float acc_vector_iq_noncoherent_mean_amplitude (const acc_vector_iq_t *vector_a)
 Non-coherent mean amplitude of IQ vector. More...
 
void acc_vector_iq_phase (const acc_vector_iq_t *vector_a, acc_vector_float_t *vector_out)
 Phase of an IQ vector. More...
 
uint32_t acc_vector_float_argmax (acc_vector_float_t *vector_a)
 Index of element with maximum value in a float vector. More...
 
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. More...
 
float acc_processing_helper_interpolate_peak_position (float y1, float y2, float y3)
 Interpolate peak position. More...
 
void acc_vector_float_print (const char *label, acc_vector_float_t *vector_a)
 Print float vector. More...
 
void acc_vector_iq_print (const char *label, acc_vector_iq_t *vector_a)
 Print IQ vector. More...
 

Function Documentation

◆ acc_get_iq_point_vector()

void acc_get_iq_point_vector ( const acc_control_helper_t control_helper_state,
uint32_t  point,
acc_vector_iq_t vector_out 
)

Extract an IQ vector with sweep data for a specific point from a newly captured IQ frame with multiple sweeps.

The resulting vector can be used with the processing functions in this file.

Parameters
[in]control_helper_statePointer to control helper radar state struct
[in]pointThe point to get the IQ vector for
[out]vector_outIQ vector
Examples
example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, and example_processing_static_presence.c.

Definition at line 152 of file acc_processing_helpers.c.

◆ acc_get_iq_sweep_vector()

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.

The resulting vector can be used with the processing functions in this file.

Parameters
[in]control_helper_statePointer to control helper radar state struct
[out]vector_outIQ vector
Examples
example_processing_amplitude.c, example_processing_peak_interpolation.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 138 of file acc_processing_helpers.c.

◆ acc_processing_helper_dynamic_sf()

float acc_processing_helper_dynamic_sf ( float  static_sf,
uint32_t  update_count 
)

Calculate a dynamic smoothing factor.

Calculate a smoothing factor that are lower for the first sweeps. For the first n sweeps the exponential average will be equal to the arithmetic mean of the first n sweeps.

Parameters
[in]static_sfThe target smoothing factor that will be used after the first sweeps
[in]update_countThe update count should be 0 for the first sweep and increased by one for each update
Returns
Dynamic smoothing factor
Examples
example_processing_subtract_adaptive_bg.c.

Definition at line 110 of file acc_processing_helpers.c.

◆ acc_processing_helper_get_filter_length()

uint32_t acc_processing_helper_get_filter_length ( uint32_t  peak_width_points,
uint32_t  step_length 
)

Calculate filter vector length.

Calculate filter vector length given peak width and step size. The peak width varies depending on profile.

Parameters
[in]peak_width_pointsPeak width in base points
[in]step_lengthStep length in base points
Returns
Filter vector length
Examples
example_processing_peak_interpolation.c.

Definition at line 166 of file acc_processing_helpers.c.

◆ acc_processing_helper_interpolate_peak_position()

float acc_processing_helper_interpolate_peak_position ( float  y1,
float  y2,
float  y3 
)

Interpolate peak position.

The function fits a second degree polynomial to three consecutive amplitude values where second element is expected to contain the maximum measured amplitude. The function then finds the position of the maximum amplitude of the polynomial. The position is normalized and a return value of 0 means that the peak is at the position of the second amplitude. A value of -1 and 1 means that the peak is at the position of the first or third input amplitude respectively.

Parameters
[in]y1The first amplitude value
[in]y2The second amplitude value
[in]y3The third amplitude value
Returns
Interpolated peak position
Examples
example_processing_peak_interpolation.c.

Definition at line 395 of file acc_processing_helpers.c.

◆ acc_processing_helper_tc_to_sf()

float acc_processing_helper_tc_to_sf ( float  time_constant_s,
float  update_rate_hz 
)

Convert time constant to smoothing factor.

Parameters
[in]time_constant_sTime constant
[in]update_rate_hzUpdate rate
Returns
Smoothing factor
Examples
example_processing_subtract_adaptive_bg.c.

Definition at line 97 of file acc_processing_helpers.c.

◆ acc_vector_float_alloc()

acc_vector_float_t* acc_vector_float_alloc ( uint32_t  data_length)

Allocate storage for a float vector.

Parameters
[in]data_lengthLength of the vector
Returns
Pointer to vector or NULL if allocation failed
Examples
example_processing_amplitude.c, example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, example_processing_peak_interpolation.c, example_processing_static_presence.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 50 of file acc_processing_helpers.c.

◆ acc_vector_float_argmax()

uint32_t acc_vector_float_argmax ( acc_vector_float_t vector_a)

Index of element with maximum value in a float vector.

Parameters
[in]vector_aInput vector
Returns
The index of the element with the highest value
Examples
example_processing_amplitude.c, example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 357 of file acc_processing_helpers.c.

◆ acc_vector_float_argmax_skip_edges()

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.

Find the index of the maximum element in a float vector disregarding the first and last elements in the vector.

Parameters
[in]vector_aInput vector
[in]elements_to_skipThe number of elements to skip
Returns
The index of the element with the highest value
Examples
example_processing_peak_interpolation.c.

Definition at line 375 of file acc_processing_helpers.c.

◆ acc_vector_float_create_depth_filter_vector()

void acc_vector_float_create_depth_filter_vector ( acc_vector_float_t vector_out)

Create a distance filter vector.

Create a triangle shaped distance filter vector. Use the function acc_processing_helper_get_filter_length when allocating memory for the output vector to get the right length of the filter for a given peak width and step size.

Parameters
[out]vector_outFilter vector
Examples
example_processing_peak_interpolation.c.

Definition at line 172 of file acc_processing_helpers.c.

◆ acc_vector_float_free()

void acc_vector_float_free ( acc_vector_float_t vector)

◆ acc_vector_float_print()

void acc_vector_float_print ( const char *  label,
acc_vector_float_t vector_a 
)

Print float vector.

Print a float vector to stdout.

Parameters
[in]labelA string description of the vector
[in]vector_aThe float vector to print
Examples
example_processing_amplitude.c, example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 401 of file acc_processing_helpers.c.

◆ acc_vector_float_update_exponential_average()

void acc_vector_float_update_exponential_average ( const acc_vector_float_t current,
acc_vector_float_t averaged_data,
float  sf 
)

Update the exponential average of a float vector.

Parameters
[in]currentThe new IQ float that will be included in the updated exponential average
[in,out]averaged_dataThe filtered data or exponential average that should be updated
[in]sfSmoothing factor that determines how much of the old data that should be kept

Definition at line 127 of file acc_processing_helpers.c.

◆ acc_vector_iq_add()

void acc_vector_iq_add ( const acc_vector_iq_t vector_a,
const acc_vector_iq_t vector_b,
acc_vector_iq_t vector_out 
)

Add two IQ vectors.

Parameters
[in]vector_aFirst input vector
[in]vector_bSecond input vector
[out]vector_outThe result a + b

Definition at line 237 of file acc_processing_helpers.c.

◆ acc_vector_iq_alloc()

acc_vector_iq_t* acc_vector_iq_alloc ( uint32_t  data_length)

Allocate storage for an IQ vector.

Parameters
[in]data_lengthLength of the vector
Returns
Pointer to vector or NULL if allocation failed
Examples
example_processing_amplitude.c, example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, example_processing_peak_interpolation.c, example_processing_static_presence.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 27 of file acc_processing_helpers.c.

◆ acc_vector_iq_amplitude()

void acc_vector_iq_amplitude ( const acc_vector_iq_t vector_a,
acc_vector_float_t vector_out 
)

Amplitude of an IQ vector.

Calculate the amplitude of the elements in an IQ vector.

Parameters
[in]vector_aInput IQ vector
[out]vector_outThe amplitude of the elements in the input vector
Examples
example_processing_amplitude.c, example_processing_peak_interpolation.c, and example_processing_subtract_adaptive_bg.c.

Definition at line 305 of file acc_processing_helpers.c.

◆ acc_vector_iq_apply_filter()

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.

Performs coherent filtering of the input vector.

Parameters
[in]vector_aIQ vector
[in]filter_vectorFilter vector
[out]vector_outFiltered result
Examples
example_processing_peak_interpolation.c.

Definition at line 203 of file acc_processing_helpers.c.

◆ acc_vector_iq_coherent_mean_amplitude()

float acc_vector_iq_coherent_mean_amplitude ( const acc_vector_iq_t vector_a)

Coherent mean amplitude of IQ vector.

Calculate the coherent mean amplitude of the elements in an IQ vector.

Parameters
[in]vector_aInput IQ vector
Returns
The coherent mean amplitude of the elements in vector_a
Examples
example_processing_coherent_mean.c, and example_processing_static_presence.c.

Definition at line 316 of file acc_processing_helpers.c.

◆ acc_vector_iq_conj_inline()

void acc_vector_iq_conj_inline ( acc_vector_iq_t vector_a)

Update an IQ vector with its conjugate.

Replace the elements in an IQ vector with the conjugate of the elements.

Parameters
[in,out]vector_aThe IQ vector to be modified

Definition at line 296 of file acc_processing_helpers.c.

◆ acc_vector_iq_copy()

void acc_vector_iq_copy ( const acc_vector_iq_t vector_a,
acc_vector_iq_t vector_out 
)

Copy an IQ vector.

Copy the contents of one IQ vector to another IQ vector.

Parameters
[in]vector_aSource IQ vector
[out]vector_outDestination IQ vector

Definition at line 226 of file acc_processing_helpers.c.

◆ acc_vector_iq_free()

void acc_vector_iq_free ( acc_vector_iq_t vector)

◆ acc_vector_iq_mult()

void acc_vector_iq_mult ( const acc_vector_iq_t vector_a,
const acc_vector_iq_t vector_b,
acc_vector_iq_t vector_out 
)

Multiply two IQ vectors.

Perform element wise multiplication of two IQ vectors.

Parameters
[in]vector_aFirst input vector
[in]vector_bSecond input vector
[out]vector_outThe result a * b

Definition at line 261 of file acc_processing_helpers.c.

◆ acc_vector_iq_mult_conj()

void acc_vector_iq_mult_conj ( const acc_vector_iq_t vector_a,
const acc_vector_iq_t vector_b,
acc_vector_iq_t vector_out 
)

Multiply first IQ vector with conjugate of second IQ vector.

Make element wise multiplication of an IQ vector with the conjugate of another IQ vector. The amplitudes of the result will be the product of the amplitudes of the input vectors. The phases of the result will be the phase differences of the two input vectors.

The function can be used when calculating the phase difference between two consecutive sweeps.

Parameters
[in]vector_aFirst input vector
[in]vector_bSecond input vector
[out]vector_outThe result: a * conj(b)

Definition at line 273 of file acc_processing_helpers.c.

◆ acc_vector_iq_noncoherent_mean_amplitude()

float acc_vector_iq_noncoherent_mean_amplitude ( const acc_vector_iq_t vector_a)

Non-coherent mean amplitude of IQ vector.

Calculate the non-coherent mean amplitude of the elements in an IQ vector.

Parameters
[in]vector_aInput IQ vector
Returns
The non-coherent mean amplitude of the elements in vector_a
Examples
example_processing_noncoherent_mean.c, and example_processing_static_presence.c.

Definition at line 331 of file acc_processing_helpers.c.

◆ acc_vector_iq_phase()

void acc_vector_iq_phase ( const acc_vector_iq_t vector_a,
acc_vector_float_t vector_out 
)

Phase of an IQ vector.

Calculate the phase of the elements in an IQ vector.

Parameters
[in]vector_aInput IQ vector
[out]vector_outThe phase of the elements in the input vector

Definition at line 346 of file acc_processing_helpers.c.

◆ acc_vector_iq_print()

void acc_vector_iq_print ( const char *  label,
acc_vector_iq_t vector_a 
)

Print IQ vector.

Print an IQ vector to stdout.

Parameters
[in]labelA string description of the vector
[in]vector_aThe IQ vector to print

Definition at line 423 of file acc_processing_helpers.c.

◆ acc_vector_iq_rotate_phase_inline()

void acc_vector_iq_rotate_phase_inline ( acc_vector_iq_t vector_a,
float  radians 
)

Rotate the phase of elements in an IQ vector.

Parameters
[in,out]vector_aThe IQ vector to be modified
[in]radiansThe angle in radians to rotate the phase

Definition at line 285 of file acc_processing_helpers.c.

◆ acc_vector_iq_subtract()

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.

Parameters
[in]vector_aFirst input vector
[in]vector_bSecond input vector
[out]vector_outThe result a - b
Examples
example_processing_subtract_adaptive_bg.c.

Definition at line 249 of file acc_processing_helpers.c.

◆ acc_vector_iq_update_exponential_average()

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.

Parameters
[in]currentThe new IQ vector that will be included in the updated exponential average
[in,out]averaged_dataThe filtered data or exponential average that should be updated
[in]sfSmoothing factor that determines how much of the old data that should be kept
Examples
example_processing_subtract_adaptive_bg.c.

Definition at line 116 of file acc_processing_helpers.c.