PGTypes.h 5.19 KB
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
1
/*
2
 * Copyright 2007, 2008, 2009, 2010,
Thomas Moulard's avatar
Thomas Moulard committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * Mehdi    Benallegue
 * Andrei   Herdt
 * Francois Keith
 * Olivier  Stasse
 *
 * JRL, CNRS/AIST
 *
 * This file is part of walkGenJrl.
 * walkGenJrl is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * walkGenJrl is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with walkGenJrl.  If not, see <http://www.gnu.org/licenses/>.
 *
24
 *  Research carried out within the scope of the
Thomas Moulard's avatar
Thomas Moulard committed
25
26
27
28
29
30
31
32
33
34
 *  Joint Japanese-French Robotics Laboratory (JRL)
 */
/*! \file PGTypes.h
    \brief Defines basic types for the Humanoid Walking Pattern Generator.
*/
#ifndef _PATTERN_GENERATOR_TYPES_H_
#define  _PATTERN_GENERATOR_TYPES_H_

// For Windows compatibility.
#if defined (WIN32)
35
#  ifdef walkGenJrl_EXPORTS
Thomas Moulard's avatar
Thomas Moulard committed
36
#    define WALK_GEN_JRL_EXPORT __declspec(dllexport)
37
#  else
Thomas Moulard's avatar
Thomas Moulard committed
38
#    define WALK_GEN_JRL_EXPORT __declspec(dllimport)
39
#  endif
Thomas Moulard's avatar
Thomas Moulard committed
40
41
42
43
44
45
46
47
48
49
#else
#  define WALK_GEN_JRL_EXPORT
#endif

#include <MatrixAbstractLayer/MatrixAbstractLayer.h>

namespace PatternGeneratorJRL
{
  struct COMState_s;

50
  /// Structure to store the COM position computed by the preview control.
Thomas Moulard's avatar
Thomas Moulard committed
51
52
  struct WALK_GEN_JRL_EXPORT COMPosition_s
  {
53
54
    double x[3],y[3];
    double z[3];
Thomas Moulard's avatar
Thomas Moulard committed
55
56
    double yaw; // aka theta
    double pitch; // aka omega
57
58
    double roll; // aka hip

Thomas Moulard's avatar
Thomas Moulard committed
59
    struct COMPosition_s & operator=(const COMState_s &aCS);
60

Thomas Moulard's avatar
Thomas Moulard committed
61
62
63
64
65
66
67
68
69
70
71
72
  };

  typedef struct COMPosition_s COMPosition;
  typedef struct COMPosition_s WaistState;

  /// Structure to store the COM state computed by the preview control.
  struct WALK_GEN_JRL_EXPORT COMState_s
  {
    double x[3],y[3],z[3];
    double yaw[3]; // aka theta
    double pitch[3]; // aka omega
    double roll[3]; // aka hip
73

Thomas Moulard's avatar
Thomas Moulard committed
74
    struct COMState_s & operator=(const COMPosition_s &aCS);
75
76

    void reset();
Thomas Moulard's avatar
Thomas Moulard committed
77
78
79
80
81

    COMState_s();
  };

  typedef struct COMState_s COMState;
82
83

  /** Structure to store each foot position when the user is specifying
Thomas Moulard's avatar
Thomas Moulard committed
84
85
      a sequence of relative positions. */
  struct RelativeFootPosition_s
86
  {
Thomas Moulard's avatar
Thomas Moulard committed
87
88
89
90
91
    double sx,sy,theta;
    float SStime;
    float DStime;
    int stepType;     //1:normal walking 2:one step before opbstacle
                      //3:first leg over obstacle 4:second leg over obstacle 5:one step after obstacle
92
    double DeviationHipHeight;
Thomas Moulard's avatar
Thomas Moulard committed
93
94
95
96
97
98
   };
  typedef struct RelativeFootPosition_s RelativeFootPosition;

  /** Structure to store each of the ZMP value, with a given
      direction at a certain time. */
  struct ZMPPosition_s
99
  {
Thomas Moulard's avatar
Thomas Moulard committed
100
101
102
103
104
105
    double px,py,pz;
    double theta;//For COM
    double time;
    int stepType;     //1:normal walking 2:one step before opbstacle
                      //3:first leg over obstacle 4:second leg over obstacle 5:one step after obstacle
			//+10 if duoble support phase
106
			//*(-1) if right foot stance else left foot stance
Thomas Moulard's avatar
Thomas Moulard committed
107
108
109
110
111
112
  };
  typedef struct ZMPPosition_s ZMPPosition;

  //TODO 0: FootAbsolutePosition_t does not contain the acceleration
  /// Structure to store the absolute foot position.
  struct FootAbsolutePosition_t
113
  {
Thomas Moulard's avatar
Thomas Moulard committed
114
    /*! px, py in meters, theta in DEGREES. */
115
    double x,y,z, theta, omega, omega2;
Thomas Moulard's avatar
Thomas Moulard committed
116
    /*! Speed of the foot. */
117
    double dx,dy,dz, dtheta, domega, domega2;
Thomas Moulard's avatar
Thomas Moulard committed
118
119
120
121
122
123
    /*! Time at which this position should be reached. */
    double time;
    /*! 1:normal walking 2:one step before opbstacle
      3:first leg over obstacle 4:second leg over obstacle 5:one step after obstacle
      +10 if double support phase
      (-1) if support foot  */
124
    int stepType;
Thomas Moulard's avatar
Thomas Moulard committed
125
126
127
128
129
130
131
132
133
134
135
136
  };
  typedef struct FootAbsolutePosition_t FootAbsolutePosition;

  // Linear constraint.
  struct LinearConstraintInequality_s
  {
    MAL_MATRIX(A,double);
    MAL_MATRIX(B,double);
    MAL_VECTOR(Center,double);
    std::vector<int> SimilarConstraints;
    double StartingTime, EndingTime;
  };
137
  typedef struct LinearConstraintInequality_s
Thomas Moulard's avatar
Thomas Moulard committed
138
    LinearConstraintInequality_t;
139

Thomas Moulard's avatar
Thomas Moulard committed
140
141
142
143
144
145
146
  /// Linear constraints with variable feet placement.
  struct LinearConstraintInequalityFreeFeet_s
  {
    MAL_MATRIX(D,double);
    MAL_MATRIX(Dc,double);
    int StepNumber;
  };
147
  typedef struct LinearConstraintInequalityFreeFeet_s
Thomas Moulard's avatar
Thomas Moulard committed
148
149
150
151
152
153
154
155
    LinearConstraintInequalityFreeFeet_t;

  //State of the feet on the ground
  struct SupportFeet_s
  {
    double x,y,theta,StartTime;
    int SupportFoot;
  };
156
  typedef struct SupportFeet_s
Thomas Moulard's avatar
Thomas Moulard committed
157
158
159
160
    SupportFeet_t;

  /// Structure to store the absolute reference.
  struct ReferenceAbsoluteVelocity_t
161
  {
Thomas Moulard's avatar
Thomas Moulard committed
162
163
164
165
    /*! m/sec or degrees/sec */
    double x,y,z, dYaw;

    /*! reference values for the whole preview window */
166
    MAL_VECTOR(RefVectorX,double);
Thomas Moulard's avatar
Thomas Moulard committed
167
168
169
170
    MAL_VECTOR(RefVectorY,double);
    MAL_VECTOR(RefVectorTheta,double);
  };
  typedef struct ReferenceAbsoluteVelocity_t ReferenceAbsoluteVelocity;
171
172
173
174
175
176
177
178
179

  // State of the support
  struct SupportState_s
  {
       int Phase, Foot, StepsLeft, StepNumber;
       bool SSSS, StateChanged;
       double TimeLimit;
  };
  typedef struct SupportState_s SupportState_t;
180

Thomas Moulard's avatar
Thomas Moulard committed
181
182
};
#endif