These are the core files for the Robot at Team conception.

Dependencies:   mbed UniServ

LowpassFilter.h

Committer:
Paulhd182
Date:
2017-05-26
Revision:
2:644553c019c5

File content as of revision 2:644553c019c5:

/*
 * LowpassFilter.h
 * Copyright (c) 2016, ZHAW honr
 * All rights reserved.
 */
 
#ifndef LOWPASS_FILTER_H_
#define LOWPASS_FILTER_H_
 
#include <cstdlib>
#include <cmath>
 
/**
 * This class implements a time-discrete 2nd order low-pass filter for a series of data values.
 * This filter can typically be used within a periodic task that takes measurements that need
 * to be filtered, like speed or position values.
 */
class LowpassFilter {
     
    public:
     
                LowpassFilter();
        virtual ~LowpassFilter();
        void    reset();
        void    reset(float value);
        void    setPeriod(float period);
        void    setFrequency(float frequency);
        float   getFrequency();
        float   filter(float value);
         
    private:
         
        float   period;
        float   frequency;
        float   a11, a12, a21, a22, b1, b2;
        float   x1, x2;
};
 
#endif /* LOWPASS_FILTER_H_ */