NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LimpState.h
1 #ifndef LIMPSTATE_H_
2 #define LIMPSTATE_H_
3 
4 namespace margait_contrib
5 {
6 
7 struct LimpState;
8 
9 extern LimpState operator*(const double scalar, const LimpState& v);
10 extern LimpState operator*(const LimpState& v, const double scalar);
11 
12 struct LimpState
13 {
14  double x;
15  double vx;
16  double ax;
17  double y;
18  double vy;
19  double ay;
20  double energyX;
21  double energyY;
22  int supportLegSign;
23 
24  LimpState()
25  {
26  reset();
27  }
28 
29  LimpState(double x, double y, double vx = 0.0, double vy = 0.0, double ax = 0.0, double ay = 0.0)
30  {
31  set(x, y, vx, vy, ax, ay);
32  }
33 
34  void set(double x, double y, double vx = 0.0, double vy = 0.0, double ax = 0.0, double ay = 0.0)
35  {
36  this->x = x;
37  this->vx = vx;
38  this->ax = ax;
39  this->y = y;
40  this->vy = vy;
41  this->ay = ay;
42  energyX = 0;
43  energyY = 0;
44  supportLegSign = 1;
45  }
46 
47  void reset()
48  {
49  x = 0;
50  vx = 0;
51  ax = 0;
52  y = 0;
53  vy = 0;
54  ay = 0;
55  energyX = 0;
56  energyY = 0;
57  supportLegSign = 1;
58  }
59 
60  inline LimpState operator+(const LimpState& v) const
61  {
62  LimpState lm = *this;
63  lm.x += v.x;
64  lm.vx += v.vx;
65  lm.y += v.y;
66  lm.vy += v.vy;
67  return lm;
68  }
69  inline LimpState operator-() const
70  {
71  LimpState lm = *this;
72  lm.x = -lm.x;
73  lm.vx = -lm.vx;
74  lm.y = -lm.y;
75  lm.vy = -lm.vy;
76 
77  return lm;
78  }
79  inline LimpState operator-(const LimpState& v) const
80  {
81  LimpState lm = *this;
82  lm.x -= v.x;
83  lm.vx -= v.vx;
84  lm.y -= v.y;
85  lm.vy -= v.vy;
86  return lm;
87  }
88  inline void operator+=(const LimpState& v)
89  {
90  x+=v.x;
91  vx+=v.vx;
92  y+=v.y;
93  vy+=v.vy;
94  }
95  inline void operator-=(const LimpState& v)
96  {
97  x-=v.x;
98  vx-=v.vx;
99  y-=v.y;
100  vy-=v.vy;
101  }
102  inline void operator*=(const double scalar)
103  {
104  x*=scalar;
105  vx*=scalar;
106  y*=scalar;
107  vy*=scalar;
108  }
109  inline void operator/=(const double scalar)
110  {
111  x/=scalar;
112  vx/=scalar;
113  y/=scalar;
114  vy/=scalar;
115  }
116  inline bool operator==(const LimpState& v) const
117  {
118  return (x==v.x) && (vx==v.vx) && (y==v.y) && (vy==v.vy);
119  }
120  inline bool operator!=(const LimpState& v) const
121  {
122  return (x!=v.x) || (vx!=v.vx) || (y!=v.y) || (vy!=v.vy);
123  }
124 };
125 
126 }
127 
128 #endif