StationaryOffset.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  *
4  * This file is inspired by Stephane's Caron original implementation as part of
5  * lipm_walking_controller <https://github.com/stephane-caron/lipm_walking_controller>
6  */
7 
8 #pragma once
9 
11 
12 namespace mc_filter
13 {
21 template<typename VectorT>
23 {
34  StationaryOffset(double dt, double timeConstant, const VectorT & initValue = VectorT::Zero())
35  : average_(dt, timeConstant, initValue)
36  {
37  this->reset(initValue);
38  }
39 
45  void update(const VectorT & value)
46  {
47  average_.append(value);
48  filteredValue_ = value - average_.eval();
49  if(saturation_ > 0.) { utils::clampInPlace(filteredValue_, -saturation_, saturation_); }
50  }
51 
55  const VectorT & eval() const { return filteredValue_; }
56 
61  void reset(const VectorT & initValue)
62  {
63  average_.reset(initValue);
64  filteredValue_ = initValue;
65  }
66 
70  double timeConstant() const { return average_.timeConstant(); }
71 
77  void timeConstant(double T) { average_.timeConstant(T); }
78 
83  void saturation(double limit) { saturation_ = limit; }
84 
85 private:
86  VectorT filteredValue_ = VectorT::Zero();
88  double saturation_ = -1;
89 };
90 } // namespace mc_filter
mc_filter::StationaryOffset::saturation
void saturation(double limit)
Definition: StationaryOffset.h:83
ExponentialMovingAverage.h
mc_filter::StationaryOffset::reset
void reset(const VectorT &initValue)
Definition: StationaryOffset.h:61
mc_filter
Definition: ExponentialMovingAverage.h:14
mc_filter::StationaryOffset::timeConstant
void timeConstant(double T)
Definition: StationaryOffset.h:77
mc_filter::StationaryOffset::eval
const VectorT & eval() const
Definition: StationaryOffset.h:55
mc_filter::StationaryOffset::update
void update(const VectorT &value)
Definition: StationaryOffset.h:45
mc_filter::StationaryOffset::StationaryOffset
StationaryOffset(double dt, double timeConstant, const VectorT &initValue=VectorT::Zero())
Definition: StationaryOffset.h:34
mc_filter::utils::clampInPlace
void clampInPlace(double &value, double lower, double upper)
Definition: clamp.h:38
mc_filter::StationaryOffset::timeConstant
double timeConstant() const
Definition: StationaryOffset.h:70
mc_filter::ExponentialMovingAverage
Definition: ExponentialMovingAverage.h:39
mc_filter::StationaryOffset
Definition: StationaryOffset.h:22