Macros | Functions
acc_processing_helpers.c File Reference
`#include <assert.h>`
`#include <complex.h>`
`#include <math.h>`
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "acc_control_helper.h"`
`#include "acc_processing_helpers.h"`
`#include "acc_integration_log.h"`

Go to the source code of this file.

## Macros
#define | MAX_DATA_ENTRY_LEN_IQ 87
#define | MAX_DATA_ENTRY_LEN_FLOAT 44

## Functions
acc_vector_iq_t * | acc_vector_iq_alloc (uint32_t data_length)
| Allocate storage for an IQ vector. More...
acc_vector_float_t * | acc_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 elemets_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...

## Macro Definition Documentation

## ◆ MAX_DATA_ENTRY_LEN_FLOAT

#define MAX_DATA_ENTRY_LEN_FLOAT 44

Examples
  acc_processing_helpers.c.

Definition at line 24 of file acc_processing_helpers.c.

## ◆ MAX_DATA_ENTRY_LEN_IQ

#define MAX_DATA_ENTRY_LEN_IQ 87

Examples
  acc_processing_helpers.c.

Definition at line 23 of file acc_processing_helpers.c.

## 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_state | Pointer to control helper radar state struct
  [in] | point | The point to get the IQ vector for
  [out] | vector_out | IQ vector

Examples
  acc_processing_helpers.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_state | Pointer to control helper radar state struct
  [out] | vector_out | IQ vector

Examples
  acc_processing_helpers.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_sf | The target smoothing factor that will be used after the first sweeps
  [in] | update_count | The update count should be 0 for the first sweep and increased by one for each update

Returns
  Dynamic smoothing factor

Examples
  acc_processing_helpers.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_points | Peak width in base points
  [in] | step_length | Step length in base points

Returns
  Filter vector length

Examples
  acc_processing_helpers.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] | y1 | The first amplitude value
  [in] | y2 | The second amplitude value
  [in] | y3 | The third amplitude value

Returns
  Interpolated peak position

Examples
  acc_processing_helpers.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_s | Time constant
  [in] | update_rate_hz | Update rate

Returns
  Smoothing factor

Examples
  acc_processing_helpers.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_length | Length of the vector

Returns
  Pointer to vector or NULL if allocation failed

Examples
  acc_processing_helpers.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_a | Input vector

Returns
  The index of the element with the highest value

Examples
  acc_processing_helpers.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_a | Input vector
  [in] | elements_to_skip | The number of elements to skip

Returns
  The index of the element with the highest value

Examples
  acc_processing_helpers.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_out | Filter vector

Examples
  acc_processing_helpers.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 | ) |

Free storage of data elements in a float vector.

Parameters

  [in] | vector | Vector to be freed

Examples
  acc_processing_helpers.c.

Definition at line 85 of file acc_processing_helpers.c.

## ◆ 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] | label | A string description of the vector
  [in] | vector_a | The float vector to print

Examples
  acc_processing_helpers.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] | current | The new IQ float that will be included in the updated exponential average
  [in,out] | averaged_data | The filtered data or exponential average that should be updated
  [in] | sf | Smoothing factor that determines how much of the old data that should be kept

Examples
  acc_processing_helpers.c.

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_a | First input vector
  [in] | vector_b | Second input vector
  [out] | vector_out | The result a + b

Examples
  acc_processing_helpers.c.

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_length | Length of the vector

Returns
  Pointer to vector or NULL if allocation failed

Examples
  acc_processing_helpers.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_a | Input IQ vector
  [out] | vector_out | The amplitude of the elements in the input vector

Examples
  acc_processing_helpers.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_a | IQ vector
  [in] | filter_vector | Filter vector
  [out] | vector_out | Filtered result

Examples
  acc_processing_helpers.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_a | Input IQ vector

Returns
  The coherent mean amplitude of the elements in vector_a

Examples
  acc_processing_helpers.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_a | The IQ vector to be modified

Examples
  acc_processing_helpers.c.

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_a | Source IQ vector
  [out] | vector_out | Destination IQ vector

Examples
  acc_processing_helpers.c.

Definition at line 226 of file acc_processing_helpers.c.

## ◆ acc_vector_iq_free()

void acc_vector_iq_free | ( | acc_vector_iq_t * | vector | ) |

Free storage of data elements in an IQ vector.

Parameters

  [in] | vector | Vector to be freed

Examples
  acc_processing_helpers.c.

Definition at line 73 of file acc_processing_helpers.c.

## ◆ 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_a | First input vector
  [in] | vector_b | Second input vector
  [out] | vector_out | The result a * b

Examples
  acc_processing_helpers.c.

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_a | First input vector
  [in] | vector_b | Second input vector
  [out] | vector_out | The result: a * conj(b)

Examples
  acc_processing_helpers.c.

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_a | Input IQ vector

Returns
  The non-coherent mean amplitude of the elements in vector_a

Examples
  acc_processing_helpers.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_a | Input IQ vector
  [out] | vector_out | The phase of the elements in the input vector

Examples
  acc_processing_helpers.c.

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] | label | A string description of the vector
  [in] | vector_a | The IQ vector to print

Examples
  acc_processing_helpers.c.

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_a | The IQ vector to be modified
  [in] | radians | The angle in radians to rotate the phase

Examples
  acc_processing_helpers.c.

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_a | First input vector
  [in] | vector_b | Second input vector
  [out] | vector_out | The result a - b

Examples
  acc_processing_helpers.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] | current | The new IQ vector that will be included in the updated exponential average
  [in,out] | averaged_data | The filtered data or exponential average that should be updated
  [in] | sf | Smoothing factor that determines how much of the old data that should be kept

Examples
  acc_processing_helpers.c.

Definition at line 116 of file acc_processing_helpers.c.