motor_controller
InputShaper.hpp
Go to the documentation of this file.
1 //
2 // C++ Interface: InputShaper
3 //
4 // Description: Input Shaper is command generation technique used to remove the vibrations from
5 // the system with known dynamics
6 //
7 //
8 // Author: <Ajish Babu>, (C) 2011
9 //
10 // Copyright: See COPYING file that comes with this distribution
11 //
12 //
13 #ifndef CONTROLLERINPUTSHAPERCONTROLLER_H
14 #define CONTROLLERINPUTSHAPERCONTROLLER_H
15 
16 #include <math.h>
17 #include <iostream>
18 #include <iomanip>
19 #include <vector>
20 #include <deque>
21 
22 namespace motor_controller
23 {
25  {
26  public:
28  void setCoefficients(double _Ts,
29  double _dampingRatio,
30  double _naturalFrequency,
31  int nrImpulses = 2);
32 
33  void setDirectCoefficients (double _Ts,
34  double _K,
35  double _timeDelay,
36  int _nrImpulses = 2);
37 
38  void printCoefficients();
39 
40  double update ( double _referenceInput,
41  double time = 0.0 );
42 
43  void reset() { currTime = 0.0;
44  referenceInput.clear();}
45 
46  private:
47 
48  double Ts; // Sampling time
49  double currTime; // Integrated sampling time
50 
51  int nrImpulses; // Number of modes for the input shaper
52  // higher the number of modes .... higher the robustness
53  // 2 <= nrImpulses <= 4
54  // needs to be extended for further modes if needed
55  double dampingRatio; // Damping ratio of the system
56  double naturalFrequency; // Natural frequency of the system \omega_0
57 
58  std::vector<double> amplitudes; // The impulse amplitudes
59  double K; // Step response overshoot
60  double timeDelay; // Time of the first overshoot
61 
62  double shapedCommand; // the shaped command output
63 
64  std::deque<double> referenceInput; // Stores the reference input for delayed signal
65  };
66 }
67 
68 #endif
void setDirectCoefficients(double _Ts, double _K, double _timeDelay, int _nrImpulses=2)
Definition: InputShaper.cpp:70
void setCoefficients(double _Ts, double _dampingRatio, double _naturalFrequency, int nrImpulses=2)
Definition: InputShaper.cpp:18
void printCoefficients()
Definition: InputShaper.cpp:119
void reset()
Definition: InputShaper.hpp:43
InputShaper()
Definition: InputShaper.hpp:27
Definition: InputShaper.hpp:24
double update(double _referenceInput, double time=0.0)
Definition: InputShaper.cpp:134