defs.h
Go to the documentation of this file.
1 #ifndef __DEFS_H__
2 #define __DEFS_H__
3 
4 #include <math.h>
5 
6 enum {RLEG, LLEG};
7 enum {FX, FY, FZ, MX, MY, MZ};
8 enum {X, Y, Z};
9 enum {WX, WY, WZ};
10 enum {TOE, HEEL};
11 enum {INSIDE, OUTSIDE};
12 enum {RL, FB};
13 
14 #define sgn(x) (((x)>0)?1:-1)
15 #define deg2rad(x) ((x)*M_PI/180)
16 #define rad2deg(x) ((x)*180/M_PI)
17 #define sqr(x) ((x)*(x))
18 #define LPF(dT, omega, x, y) ((y) = (((dT)*(omega)/(1+(dT)*(omega)))*(x)+1/(1+(dT)*(omega))*(y)))
19 
20 template<class T>
21 void LIMITER(T &org, const T &min_, const T &max_)
22 {
23  for (unsigned int i=0; i<org.size(); i++){
24  if (org(i) > max_(i)){
25  org(i) = max_(i);
26  }else if (org(i) < min_(i)){
27  org(i) = min_(i);
28  }
29  }
30 }
31 
32 template<class T>
33 void DEADZONE(T &org, const T &min_, const T &max_)
34 {
35  for (unsigned int i=0; i<org.size(); i++){
36  if (org(i) > max_(i)){
37  org(i) -= max_(i);
38  }else if (org(i) < min_(i)){
39  org(i) -= min_(i);
40  }else{
41  org(i) = 0;
42  }
43  }
44 }
45 
46 inline void LIMIT(double &org, const double max_)
47 {
48  if (org > max_){
49  org = max_;
50  }else if (org < -max_){
51  org = -max_;
52  }
53 }
54 
55 inline void LIMITER(double &org, const double min_, const double max_)
56 {
57  if (org > max_){
58  org = max_;
59  }else if (org < min_){
60  org = min_;
61  }
62 }
63 
64 inline void LIMITER(int &org, const int min_, const int max_)
65 {
66  if (org > max_){
67  org = max_;
68  }else if (org < min_){
69  org = min_;
70  }
71 }
72 
73 inline void DEADZONE(double &org, const double min_, const double max_)
74 {
75  if (org > max_){
76  org -= max_;
77  }else if (org < min_){
78  org -= min_;
79  }else{
80  org = 0;
81  }
82 }
83 
84 inline void HYSTERESIS(double &newv, const double old,
85  const double min_, const double max_)
86 {
87  if (old >= newv-min_){
88  newv -= min_;
89  }else if (old <= newv - max_){
90  newv -= max_;
91  }else{
92  newv = old;
93  }
94 }
95 
96 #endif
Definition: defs.h:8
Definition: defs.h:10
void HYSTERESIS(double &newv, const double old, const double min_, const double max_)
Definition: defs.h:84
Definition: defs.h:7
Definition: defs.h:8
Definition: defs.h:11
Definition: defs.h:7
png_uint_32 i
Definition: defs.h:7
Definition: defs.h:7
void LIMIT(double &org, const double max_)
Definition: defs.h:46
void LIMITER(T &org, const T &min_, const T &max_)
Definition: defs.h:21
Definition: defs.h:9
void DEADZONE(T &org, const T &min_, const T &max_)
Definition: defs.h:33
Definition: defs.h:7
Definition: defs.h:6
Definition: defs.h:8
Definition: defs.h:12
Definition: defs.h:9
Definition: defs.h:10
Definition: defs.h:7
Definition: defs.h:9
Definition: defs.h:12
Definition: defs.h:11
Definition: defs.h:6


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:49