pgtypes.hh 5.12 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
 *  Joint Japanese-French Robotics Laboratory (JRL)
 */
/*! \file PGTypes.h
Olivier Stasse's avatar
Olivier Stasse committed
28
  \brief Defines basic types for the Humanoid Walking Pattern Generator.
Thomas Moulard's avatar
Thomas Moulard committed
29
30
31
32
33
34
*/
#ifndef _PATTERN_GENERATOR_TYPES_H_
#define  _PATTERN_GENERATOR_TYPES_H_

// For Windows compatibility.
#if defined (WIN32)
Francois Keith's avatar
Francois Keith committed
35
#  ifdef jrl_walkgen_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
#else
#  define WALK_GEN_JRL_EXPORT
#endif
olivier stasse's avatar
olivier stasse committed
43
44
#include <iostream>
#include <fstream>
45
#include <jrl/mal/matrixabstractlayer.hh>
Thomas Moulard's avatar
Thomas Moulard committed
46
47
48
49
50

namespace PatternGeneratorJRL
{
  struct COMState_s;

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

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

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

  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
74

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

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

    COMState_s();
olivier stasse's avatar
olivier stasse committed
80
81

    friend std::ostream & operator<<(std::ostream &os, const struct COMState_s & acs);
Thomas Moulard's avatar
Thomas Moulard committed
82
  };
olivier stasse's avatar
olivier stasse committed
83
84
    
  
Thomas Moulard's avatar
Thomas Moulard committed
85
86

  typedef struct COMState_s COMState;
87
88

  /** Structure to store each foot position when the user is specifying
Thomas Moulard's avatar
Thomas Moulard committed
89
90
      a sequence of relative positions. */
  struct RelativeFootPosition_s
91
  {
Thomas Moulard's avatar
Thomas Moulard committed
92
    double sx,sy,theta;
olivier-stasse's avatar
olivier-stasse committed
93
94
    double SStime;
    double DStime;
Francois Keith's avatar
Francois Keith committed
95
    int stepType;     //1:normal walking 2:one step before obstacle
Thomas Moulard's avatar
Thomas Moulard committed
96
                      //3:first leg over obstacle 4:second leg over obstacle 5:one step after obstacle
97
    double DeviationHipHeight;
Olivier Stasse's avatar
Olivier Stasse committed
98
  };
Thomas Moulard's avatar
Thomas Moulard committed
99
100
101
102
103
  typedef struct RelativeFootPosition_s RelativeFootPosition;

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

  /// Structure to store the absolute foot position.
  struct FootAbsolutePosition_t
117
  {
Thomas Moulard's avatar
Thomas Moulard committed
118
    /*! px, py in meters, theta in DEGREES. */
119
    double x,y,z, theta, omega, omega2;
Thomas Moulard's avatar
Thomas Moulard committed
120
    /*! Speed of the foot. */
121
    double dx,dy,dz, dtheta, domega, domega2;
Andrei's avatar
Andrei committed
122
123
    /*! Acceleration of the foot. */
    double ddx,ddy,ddz, ddtheta, ddomega, ddomega2;
Thomas Moulard's avatar
Thomas Moulard committed
124
125
    /*! Time at which this position should be reached. */
    double time;
Francois Keith's avatar
Francois Keith committed
126
    /*! 1:normal walking 2:one step before obstacle
Thomas Moulard's avatar
Thomas Moulard committed
127
128
129
      3:first leg over obstacle 4:second leg over obstacle 5:one step after obstacle
      +10 if double support phase
      (-1) if support foot  */
130
    int stepType;
Thomas Moulard's avatar
Thomas Moulard committed
131
132
133
134
135
136
137
138
139
140
141
142
  };
  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;
  };
143
  typedef struct LinearConstraintInequality_s
Thomas Moulard's avatar
Thomas Moulard committed
144
    LinearConstraintInequality_t;
145

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

156
157
158
159
160
161
162
163
164
  //State of the feet on the ground
  struct SupportFeet_s
  {
    double x,y,theta,StartTime;
    int SupportFoot;
  };
  typedef struct SupportFeet_s
    SupportFeet_t;

olivier-stasse's avatar
olivier-stasse committed
165
  /// Structure to store the absolute reference.
166
167
  struct ReferenceAbsoluteVelocity_t
  {
olivier-stasse's avatar
olivier-stasse committed
168
169
    /*! m/sec or degrees/sec */
    double x,y,z, dYaw;
170

olivier-stasse's avatar
olivier-stasse committed
171
172
173
174
    /*! reference values for the whole preview window */
    MAL_VECTOR(RefVectorX,double);
    MAL_VECTOR(RefVectorY,double);
    MAL_VECTOR(RefVectorTheta,double);
175
176
177
  };
  typedef struct ReferenceAbsoluteVelocity_t ReferenceAbsoluteVelocity;

olivier-stasse's avatar
olivier-stasse committed
178
}
Thomas Moulard's avatar
Thomas Moulard committed
179
#endif