Robot Control Library
filter.h File Reference
#include <stdint.h>
#include <rc/math/vector.h>
#include <rc/math/ring_buffer.h>

Go to the source code of this file.

Data Structures

struct  rc_filter_t
 Struct containing configuration and state of a SISO filter. More...
 

Macros

#define RC_FILTER_INITIALIZER
 

Typedefs

typedef struct rc_filter_t rc_filter_t
 Struct containing configuration and state of a SISO filter. More...
 

Functions

rc_filter_t rc_filter_empty (void)
 Critical function for initializing rc_filter_t structs. More...
 
int rc_filter_alloc (rc_filter_t *f, rc_vector_t num, rc_vector_t den, double dt)
 Allocate memory for a discrete-time filter & populates it with the transfer function coefficients provided in vectors num and den. More...
 
int rc_filter_alloc_from_arrays (rc_filter_t *f, double dt, double *num, int numlen, double *den, int denlen)
 Like rc_filter_alloc(), but takes arrays for the numerator and denominator coefficients instead of vectors. More...
 
int rc_filter_duplicate (rc_filter_t *f, rc_filter_t old)
 duplicates a filter More...
 
int rc_filter_free (rc_filter_t *f)
 Frees the memory allocated by a filter's buffers and coefficient vectors. Also resets all filter properties back to 0. More...
 
int rc_filter_print (rc_filter_t f)
 Prints the transfer function and other statistic of a filter to the screen. More...
 
double rc_filter_march (rc_filter_t *f, double new_input)
 March a filter forward one step with new input provided as an argument. More...
 
int rc_filter_reset (rc_filter_t *f)
 Resets all previous inputs and outputs to 0. Also resets the step counter & saturation flag. More...
 
int rc_filter_enable_saturation (rc_filter_t *f, double min, double max)
 Enables saturation between bounds min and max. More...
 
int rc_filter_get_saturation_flag (rc_filter_t *f)
 Checks if the filter saturated the last time step. More...
 
int rc_filter_enable_soft_start (rc_filter_t *f, double seconds)
 Enables soft start functionality where the output bound is gradually opened linearly from 0 to the normal saturation range. More...
 
double rc_filter_previous_input (rc_filter_t *f, int steps)
 Returns the input 'steps' back in time. Steps=0 returns most recent input. More...
 
double rc_filter_previous_output (rc_filter_t *f, int steps)
 Returns the output 'steps' back in time. Steps = 0 returns most recent output. More...
 
int rc_filter_prefill_inputs (rc_filter_t *f, double in)
 Fills all previous inputs to the filter as if they had been equal to 'in'. More...
 
int rc_filter_prefill_outputs (rc_filter_t *f, double out)
 Fills all previous outputs of the filter as if they had been equal to 'out'. More...
 
int rc_filter_multiply (rc_filter_t f1, rc_filter_t f2, rc_filter_t *out)
 Creates a new filter 'out' by multiplying f1*f2. More...
 
int rc_filter_multiply_three (rc_filter_t f1, rc_filter_t f2, rc_filter_t f3, rc_filter_t *out)
 Creates a new filter 'out' by multiplying f1*f2*f3. More...
 
int rc_filter_c2d_tustin (rc_filter_t *f, double dt, rc_vector_t num, rc_vector_t den, double w)
 Creates a discrete time filter with similar dynamics to a provided continuous time transfer function using tustin's approximation with prewarping about a frequency of interest 'w' in radians per second. More...
 
int rc_filter_normalize (rc_filter_t *f)
 Normalizes a discrete time filter so that the leading demoninator coefficient is 1. More...
 
int rc_filter_first_order_lowpass (rc_filter_t *f, double dt, double tc)
 Creates a first order low pass filter. More...
 
int rc_filter_first_order_highpass (rc_filter_t *f, double dt, double tc)
 Creates a first order high pass filter. More...
 
int rc_filter_butterworth_lowpass (rc_filter_t *f, int order, double dt, double wc)
 Creates a Butterworth low pass filter of specified order and cutoff frequency. More...
 
int rc_filter_butterworth_highpass (rc_filter_t *f, int order, double dt, double wc)
 Creates a Butterworth high pass filter of specified order and cutoff frequency. More...
 
int rc_filter_moving_average (rc_filter_t *f, int samples, double dt)
 Makes a FIR moving average filter that averages over specified number of samples. More...
 
int rc_filter_integrator (rc_filter_t *f, double dt)
 Creates a first order integrator. More...
 
int rc_filter_double_integrator (rc_filter_t *f, double dt)
 Creates a second order double integrator. More...
 
int rc_filter_pid (rc_filter_t *f, double kp, double ki, double kd, double Tf, double dt)
 Creates a discrete-time implementation of a parallel PID controller with high-frequency rolloff using the forward-Euler integration method. More...
 
int rc_filter_third_order_complement (rc_filter_t *lp, rc_filter_t *hp, double freq, double damp, double dt)
 Creates a third order symmetric complementary pair of high/low pass filters. More...