NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LimpModel.h
1 #ifndef LIMPMODEL_H_
2 #define LIMPMODEL_H_
3 
4 #include <cap_gait/contrib/Limp.h>
5 #include <cap_gait/contrib/LimpState.h>
6 #include <cap_gait/contrib/Vec2f.h>
7 #include <cap_gait/contrib/Vec3f.h>
8 #include <cap_gait/cap_gait_config.h>
9 
10 namespace margait_contrib
11 {
12 
13 struct LimpModel
14 {
15  const cap_gait::CapConfig* config;
16  double systemIterationTime;
17  double fusedAngleX;
18  double fusedAngleY;
19 
20 // char name;
21  Vec3f gcv; // input
22 
23  // current state
24  double x;
25  double vx;
26  double ax;
27  double y;
28  double vy;
29  double ay;
30  double energyX;
31  double energyY;
32  int supportLegSign;
33  bool crossing;
34  bool stalling;
35 
36  LimpState nominalState;
37  Vec2f nominalCapturePoint;
38  Vec3f nominalFootStep;
39  Vec3f nominalStepSize;
40  double nominalFootStepTHalf;
41 
42  double timeSinceStep;
43  double timeToStep;
44  double nominalTimeToStep;
45 
46  Vec2f zmp;
47  LimpState endOfStepState;
48  Vec3f footStep;
49  Vec3f stepSize;
50 
51  Vec2f rxZmp;
52  Vec2f rxCapturePoint;
53 
54 private:
55  Limp limp;
56 
57 public:
58  explicit LimpModel(const cap_gait::CapConfig* capConfig);
59  ~LimpModel(){};
60 
61  void reset()
62  {
63  LimpState ms;
64  ms.reset(); // Just to be safe
65  setState(ms, Vec3f(0.0, 0.0, 0.0)); // TODO: This is probably not such a good idea as a zero LimpState is actually highly atypical and a situation that is in unstable equilibrium, leading to possibly weird timeToStep's and so on.
66  updateInputData(systemIterationTime, 0.0, 0.0);
67  }
68 
69  inline void updateInputData(double systemIterationTime, double fusedAngleX, double fusedAngleY)
70  {
71  this->systemIterationTime = systemIterationTime;
72  this->fusedAngleX = fusedAngleX;
73  this->fusedAngleY = fusedAngleY;
74  }
75 
76  void setState(LimpState ms, Vec3f ggcv);
77  bool forwardThroughStep(double dt);
78  void forward(double dt);
79  LimpModel forwarded(double t);
80  void step(); // Make a footstep in the model
81 
82  double timeToLoc(double loc);
83  double timeToSel();
84  double timeToApex();
85 
86  LimpState mirroredToRight();
87  LimpState getMotionState();
88  LimpState getNominalState();
89  LimpState getEndOfStepState();
90  Vec2f getCapturePoint();
91 
92  inline bool operator==(const LimpModel& v) const
93  {
94  return (x==v.x) && (vx==v.vx) && (y==v.y) && (vy==v.vy);
95  }
96  inline bool operator!=(const LimpModel& v) const
97  {
98  return (x!=v.x) || (vx!=v.vx) || (y!=v.y) || (vy!=v.vy);
99  }
100 };
101 
102 }
103 
104 #endif
Configuration struct for the capture step gait.
Definition: cap_gait_config.h:21