pgtypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2007, 2008, 2009, 2010,
3  *
4  * Mehdi Benallegue
5  * Andrei Herdt
6  * Francois Keith
7  * Olivier Stasse
8  *
9  * JRL, CNRS/AIST
10  *
11  * This file is part of walkGenJrl.
12  * walkGenJrl is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * walkGenJrl is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Lesser Public License for more details.
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with walkGenJrl. If not, see <http://www.gnu.org/licenses/>.
23  *
24  * Research carried out within the scope of the
25  * Joint Japanese-French Robotics Laboratory (JRL)
26  */
30 #ifndef _PATTERN_GENERATOR_TYPES_H_
31 #define _PATTERN_GENERATOR_TYPES_H_
32 
33 // For Windows compatibility.
34 #if defined(WIN32)
35 #ifdef jrl_walkgen_EXPORTS
36 #define WALK_GEN_JRL_EXPORT __declspec(dllexport)
37 #else
38 #define WALK_GEN_JRL_EXPORT __declspec(dllimport)
39 #endif
40 #else
41 #define WALK_GEN_JRL_EXPORT
42 #endif
43 #include <Eigen/Dense>
44 #include <fstream>
45 #include <iostream>
46 #include <vector>
47 
48 namespace PatternGeneratorJRL {
49 struct COMState_s;
50 
53  double x[3], y[3];
54  double z[3];
55  double yaw; // aka theta
56  double pitch; // aka omega
57  double roll; // aka hip
58 
59  struct COMPosition_s &operator=(const COMState_s &aCS);
60 };
61 
62 inline std::ostream &operator<<(std::ostream &os, const COMPosition_s &aCp) {
63  for (size_t i = 0; i < 3; ++i) {
64  os << "x[" << i << "] " << aCp.x[i] << " y[" << i << "] " << aCp.y[i]
65  << " z[" << i << "] " << aCp.z[i] << std::endl;
66  }
67  os << "yaw " << aCp.yaw << " pitch " << aCp.pitch << " roll " << aCp.roll;
68  return os;
69 }
70 
71 typedef struct COMPosition_s COMPosition;
72 typedef struct COMPosition_s WaistState;
73 
76  double x[3], y[3], z[3];
77  double yaw[3]; // aka theta
78  double pitch[3]; // aka omega
79  double roll[3]; // aka hip
80 
81  struct COMState_s &operator=(const COMPosition_s &aCS);
82 
83  void reset();
84 
85  COMState_s();
86 
87  friend std::ostream &operator<<(std::ostream &os,
88  const struct COMState_s &acs);
89 };
90 
91 typedef struct COMState_s COMState;
92 
96  double sx, sy, sz, theta;
97  double SStime;
98  double DStime;
99  int stepType; // 1:normal walking 2:one step before obstacle
100  // 3:first leg over obstacle 4:second leg over obstacle
101  // 5:one step after obstacle 6 :stepping stair
104 };
106 
107 inline std::ostream &operator<<(std::ostream &os,
108  const RelativeFootPosition_s &rfp) {
109  os << "sx " << rfp.sx << " sy " << rfp.sy << " sz " << rfp.sz << " theta "
110  << rfp.theta << std::endl;
111  os << "SStime " << rfp.SStime << " DStime " << rfp.DStime << " stepType "
112  << rfp.stepType << " DeviationHipHeight " << rfp.DeviationHipHeight;
113  return os;
114 }
115 
119  double px, py, pz;
120  double theta; // For COM
121  double time;
122  int stepType; // 1:normal walking 2:one step before obstacle
123  // 3:first leg over obstacle 4:second leg over
124  // obstacle 5:one step after obstacle
125  // +10 if double support phase
126  // *(-1) if right foot stance else left foot stance
127 };
128 typedef struct ZMPPosition_s ZMPPosition;
129 
130 inline std::ostream &operator<<(std::ostream &os, const ZMPPosition_s &zmp) {
131  os << "px " << zmp.px << " py " << zmp.pz << " pz " << zmp.pz << " theta "
132  << zmp.theta << std::endl;
133  os << "time " << zmp.time << " stepType " << zmp.stepType;
134  return os;
135 }
136 
140  double x, y, z, theta, omega, omega2;
142  double dx, dy, dz, dtheta, domega, domega2;
148  double time;
154  int stepType;
155 };
157 
158 inline std::ostream &operator<<(std::ostream &os,
159  const FootAbsolutePosition &fap) {
160  os << "x " << fap.x << " y " << fap.y << " z " << fap.z << " theta "
161  << fap.theta << " omega " << fap.omega << " omega2 " << fap.omega2
162  << std::endl;
163  os << "dx " << fap.dx << " dy " << fap.dy << " dz " << fap.dz << " dtheta "
164  << fap.dtheta << " domega " << fap.domega << " domega2 " << fap.domega2
165  << std::endl;
166  os << "ddx " << fap.ddx << " ddy " << fap.ddy << " ddz " << fap.ddz
167  << " ddtheta " << fap.ddtheta << " ddomega " << fap.ddomega << " ddomega2 "
168  << fap.ddomega2 << std::endl;
169  os << "time " << fap.time << " stepType " << fap.stepType;
170  return os;
171 }
172 
176  double x, y, z, theta, omega, omega2;
178  double dx, dy, dz, dtheta, domega, domega2;
184  double time;
188  int stepType;
189 };
191 
192 inline std::ostream &operator<<(std::ostream &os,
193  const HandAbsolutePosition &hap) {
194  os << "x " << hap.x << " y " << hap.y << " z " << hap.z << " theta "
195  << hap.theta << " omega " << hap.omega << " omega2 " << hap.omega2
196  << std::endl;
197  os << "dx " << hap.dx << " dy " << hap.dy << " dz " << hap.dz << " dtheta "
198  << hap.dtheta << " domega " << hap.domega << " domega2 " << hap.domega2
199  << std::endl;
200  os << "ddx " << hap.ddx << " ddy " << hap.ddy << " ddz " << hap.ddz
201  << " ddtheta " << hap.ddtheta << " ddomega " << hap.ddomega << " ddomega2 "
202  << hap.ddomega2 << std::endl;
203  os << "time " << hap.time << " stepType " << hap.stepType;
204  return os;
205 }
206 
207 // Linear constraint.
209  Eigen::MatrixXd A;
210  Eigen::MatrixXd B;
211  Eigen::VectorXd Center;
212  std::vector<int> SimilarConstraints;
214 };
216 
219  Eigen::MatrixXd D;
220  Eigen::MatrixXd Dc;
222 };
225 
226 // State of the feet on the ground
228  double x, y, theta, StartTime;
230 };
232 
233 inline std::ostream &operator<<(std::ostream &os, const SupportFeet_s &sf) {
234  os << "x " << sf.x << " y " << sf.y << " theta " << sf.theta << std::endl;
235  os << " StartTime " << sf.StartTime << " SupportFoot " << sf.SupportFoot;
236  return os;
237 }
238 
242  double x, y, z, dYaw;
243 
245  Eigen::VectorXd RefVectorX;
246  Eigen::VectorXd RefVectorY;
247  Eigen::VectorXd RefVectorTheta;
248 };
250 
251 inline std::ostream &operator<<(std::ostream &os,
252  const ReferenceAbsoluteVelocity_t &rav) {
253  os << "x " << rav.x << " y " << rav.y << " z " << rav.z << " dYaw "
254  << rav.dYaw;
255  return os;
256 }
257 
259 struct Circle_t {
260  double x_0;
261  double y_0;
262  double r;
263  double margin;
264 };
265 typedef struct Circle_t Circle;
266 
267 inline std::ostream &operator<<(std::ostream &os, const Circle_t &circle) {
268  os << "x_0 " << circle.x_0 << " y_0 " << circle.y_0 << " R " << circle.r;
269  return os;
270 }
271 
273  Eigen::VectorXd CurrentConfiguration;
274  Eigen::VectorXd CurrentVelocity;
275  Eigen::VectorXd CurrentAcceleration;
276  Eigen::VectorXd ZMPTarget;
280  Eigen::VectorXd Momentum;
281 };
282 
283 } // namespace PatternGeneratorJRL
284 #endif
PatternGeneratorJRL::RelativeFootPosition_s::RelativeFootPosition_s
RelativeFootPosition_s()
PatternGeneratorJRL::RelativeFootPosition_s::SStime
double SStime
Definition: pgtypes.hh:97
PatternGeneratorJRL::SupportFeet_s::y
double y
Definition: pgtypes.hh:228
PatternGeneratorJRL::HandAbsolutePosition_t::dz
double dz
Definition: pgtypes.hh:178
PatternGeneratorJRL::HandAbsolutePosition_t::dddx
double dddx
Definition: pgtypes.hh:182
PatternGeneratorJRL::HandAbsolutePosition_t::dddtheta
double dddtheta
Definition: pgtypes.hh:182
PatternGeneratorJRL::SupportFeet_s::StartTime
double StartTime
Definition: pgtypes.hh:228
PatternGeneratorJRL::FootAbsolutePosition_t::dddomega2
double dddomega2
Definition: pgtypes.hh:146
PatternGeneratorJRL::HandAbsolutePosition_t::dtheta
double dtheta
Definition: pgtypes.hh:178
PatternGeneratorJRL::HandAbsolutePosition_t::ddy
double ddy
Definition: pgtypes.hh:180
PatternGeneratorJRL::HandAbsolutePosition_t::domega2
double domega2
Definition: pgtypes.hh:178
PatternGeneratorJRL::FootAbsolutePosition_t::stepType
int stepType
Definition: pgtypes.hh:154
PatternGeneratorJRL::HandAbsolutePosition_t::z
double z
Definition: pgtypes.hh:176
PatternGeneratorJRL::FootAbsolutePosition_t::omega
double omega
Definition: pgtypes.hh:140
PatternGeneratorJRL::LinearConstraintInequality_s::B
Eigen::MatrixXd B
Definition: pgtypes.hh:210
PatternGeneratorJRL::RelativeFootPosition_s::stepType
int stepType
Definition: pgtypes.hh:99
PatternGeneratorJRL::ZMPPosition_s::px
double px
Definition: pgtypes.hh:119
PatternGeneratorJRL::ZMPPosition_s::theta
double theta
Definition: pgtypes.hh:120
PatternGeneratorJRL::LinearConstraintInequality_s::SimilarConstraints
std::vector< int > SimilarConstraints
Definition: pgtypes.hh:212
PatternGeneratorJRL::FootAbsolutePosition_t::ddx
double ddx
Definition: pgtypes.hh:144
PatternGeneratorJRL::FootAbsolutePosition_t::time
double time
Definition: pgtypes.hh:148
PatternGeneratorJRL::FootAbsolutePosition_t::ddz
double ddz
Definition: pgtypes.hh:144
PatternGeneratorJRL::ZMPPosition_s
Definition: pgtypes.hh:118
PatternGeneratorJRL::FootAbsolutePosition_t::x
double x
Definition: pgtypes.hh:140
PatternGeneratorJRL::HandAbsolutePosition_t::theta
double theta
Definition: pgtypes.hh:176
PatternGeneratorJRL::SupportFeet_s::x
double x
Definition: pgtypes.hh:228
x
doublereal * x
Definition: qld.cpp:386
PatternGeneratorJRL::COMPosition_s::pitch
double pitch
Definition: pgtypes.hh:56
PatternGeneratorJRL::RelativeFootPosition_s::theta
double theta
Definition: pgtypes.hh:96
PatternGeneratorJRL::Circle_t::x_0
double x_0
Definition: pgtypes.hh:260
PatternGeneratorJRL::ZMPPosition_s::time
double time
Definition: pgtypes.hh:121
PatternGeneratorJRL::FootAbsolutePosition_t::ddomega2
double ddomega2
Definition: pgtypes.hh:144
PatternGeneratorJRL::HandAbsolutePosition_t::ddomega
double ddomega
Definition: pgtypes.hh:180
PatternGeneratorJRL::COMPosition_s::roll
double roll
Definition: pgtypes.hh:57
PatternGeneratorJRL::HandAbsolutePosition_t::dy
double dy
Definition: pgtypes.hh:178
PatternGeneratorJRL::LinearConstraintInequality_s::Center
Eigen::VectorXd Center
Definition: pgtypes.hh:211
PatternGeneratorJRL::HandAbsolutePosition_t::y
double y
Definition: pgtypes.hh:176
PatternGeneratorJRL::FootAbsolutePosition_t::dx
double dx
Definition: pgtypes.hh:142
WALK_GEN_JRL_EXPORT
#define WALK_GEN_JRL_EXPORT
Definition: pgtypes.hh:41
PatternGeneratorJRL::HandAbsolutePosition_t::dddomega2
double dddomega2
Definition: pgtypes.hh:182
PatternGeneratorJRL::FootAbsolutePosition_t::y
double y
Definition: pgtypes.hh:140
PatternGeneratorJRL::FootAbsolutePosition_t::omega2
double omega2
Definition: pgtypes.hh:140
PatternGeneratorJRL::operator<<
std::ostream & operator<<(std::ostream &os, const COMPosition_s &aCp)
Definition: pgtypes.hh:62
PatternGeneratorJRL::FootAbsolutePosition_t::dddy
double dddy
Definition: pgtypes.hh:146
PatternGeneratorJRL::FootAbsolutePosition_t::dddz
double dddz
Definition: pgtypes.hh:146
PatternGeneratorJRL::ControlLoopOneStepArgs::LeftFootPosition
FootAbsolutePosition LeftFootPosition
Definition: pgtypes.hh:278
PatternGeneratorJRL::Circle_t::margin
double margin
Definition: pgtypes.hh:263
PatternGeneratorJRL::FootAbsolutePosition_t::dy
double dy
Definition: pgtypes.hh:142
PatternGeneratorJRL::FootAbsolutePosition_t
Structure to store the absolute foot position.
Definition: pgtypes.hh:138
PatternGeneratorJRL::HandAbsolutePosition_t::omega2
double omega2
Definition: pgtypes.hh:176
PatternGeneratorJRL::ControlLoopOneStepArgs::CurrentVelocity
Eigen::VectorXd CurrentVelocity
Definition: pgtypes.hh:274
PatternGeneratorJRL::COMPosition_s::yaw
double yaw
Definition: pgtypes.hh:55
PatternGeneratorJRL::HandAbsolutePosition_t::ddz
double ddz
Definition: pgtypes.hh:180
PatternGeneratorJRL::SupportFeet_s
Definition: pgtypes.hh:227
PatternGeneratorJRL::Circle_t::r
double r
Definition: pgtypes.hh:262
PatternGeneratorJRL::FootAbsolutePosition_t::dddx
double dddx
Definition: pgtypes.hh:146
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t
Structure to store the absolute reference.
Definition: pgtypes.hh:240
PatternGeneratorJRL::LinearConstraintInequality_s
Definition: pgtypes.hh:208
PatternGeneratorJRL::FootAbsolutePosition_t::domega
double domega
Definition: pgtypes.hh:142
PatternGeneratorJRL::FootAbsolutePosition_t::dddomega
double dddomega
Definition: pgtypes.hh:146
PatternGeneratorJRL::COMPosition_s::z
double z[3]
Definition: pgtypes.hh:54
PatternGeneratorJRL::ZMPPosition_s::py
double py
Definition: pgtypes.hh:119
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::z
double z
Definition: pgtypes.hh:242
PatternGeneratorJRL::HandAbsolutePosition_t::dddomega
double dddomega
Definition: pgtypes.hh:182
PatternGeneratorJRL::Circle_t
Structure to model a circle (e.g : a stricly convex obstable)
Definition: pgtypes.hh:259
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::y
double y
Definition: pgtypes.hh:242
PatternGeneratorJRL::RelativeFootPosition_s::sz
double sz
Definition: pgtypes.hh:96
PatternGeneratorJRL::ControlLoopOneStepArgs::Momentum
Eigen::VectorXd Momentum
Definition: pgtypes.hh:280
PatternGeneratorJRL::COMPosition_s
Structure to store the COM position computed by the preview control.
Definition: pgtypes.hh:52
PatternGeneratorJRL::FootAbsolutePosition_t::dz
double dz
Definition: pgtypes.hh:142
PatternGeneratorJRL::HandAbsolutePosition_t::omega
double omega
Definition: pgtypes.hh:176
PatternGeneratorJRL::ZMPPosition_s::stepType
int stepType
Definition: pgtypes.hh:122
PatternGeneratorJRL::FootAbsolutePosition_t::theta
double theta
Definition: pgtypes.hh:140
PatternGeneratorJRL::HandAbsolutePosition_t::x
double x
Definition: pgtypes.hh:176
PatternGeneratorJRL::HandAbsolutePosition_t::ddtheta
double ddtheta
Definition: pgtypes.hh:180
PatternGeneratorJRL::SupportFeet_s::theta
double theta
Definition: pgtypes.hh:228
PatternGeneratorJRL::LinearConstraintInequalityFreeFeet_s::StepNumber
int StepNumber
Definition: pgtypes.hh:221
PatternGeneratorJRL::RelativeFootPosition_s::sx
double sx
Definition: pgtypes.hh:96
PatternGeneratorJRL::HandAbsolutePosition_t
Structure to store the absolute foot position.
Definition: pgtypes.hh:174
PatternGeneratorJRL::ControlLoopOneStepArgs::RightFootPosition
FootAbsolutePosition RightFootPosition
Definition: pgtypes.hh:279
PatternGeneratorJRL::HandAbsolutePosition_t::dx
double dx
Definition: pgtypes.hh:178
PatternGeneratorJRL::RelativeFootPosition_s
Definition: pgtypes.hh:95
PatternGeneratorJRL::FootAbsolutePosition_t::ddy
double ddy
Definition: pgtypes.hh:144
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::x
double x
Definition: pgtypes.hh:242
PatternGeneratorJRL::FootAbsolutePosition_t::domega2
double domega2
Definition: pgtypes.hh:142
PatternGeneratorJRL::LinearConstraintInequality_s::EndingTime
double EndingTime
Definition: pgtypes.hh:213
PatternGeneratorJRL::FootAbsolutePosition_t::z
double z
Definition: pgtypes.hh:140
PatternGeneratorJRL::FootAbsolutePosition_t::dtheta
double dtheta
Definition: pgtypes.hh:142
PatternGeneratorJRL::ControlLoopOneStepArgs
Definition: pgtypes.hh:272
PatternGeneratorJRL::FootAbsolutePosition_t::ddomega
double ddomega
Definition: pgtypes.hh:144
PatternGeneratorJRL::RelativeFootPosition_s::DStime
double DStime
Definition: pgtypes.hh:98
PatternGeneratorJRL::HandAbsolutePosition_t::ddx
double ddx
Definition: pgtypes.hh:180
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::RefVectorTheta
Eigen::VectorXd RefVectorTheta
Definition: pgtypes.hh:247
PatternGeneratorJRL::HandAbsolutePosition_t::ddomega2
double ddomega2
Definition: pgtypes.hh:180
PatternGeneratorJRL::HandAbsolutePosition_t::domega
double domega
Definition: pgtypes.hh:178
PatternGeneratorJRL::LinearConstraintInequalityFreeFeet_s::Dc
Eigen::MatrixXd Dc
Definition: pgtypes.hh:220
PatternGeneratorJRL
\doc Simulate a rigid body
Definition: patterngeneratorinterface.hh:41
PatternGeneratorJRL::HandAbsolutePosition_t::dddy
double dddy
Definition: pgtypes.hh:182
PatternGeneratorJRL::RelativeFootPosition_s::DeviationHipHeight
double DeviationHipHeight
Definition: pgtypes.hh:102
PatternGeneratorJRL::RelativeFootPosition_s::sy
double sy
Definition: pgtypes.hh:96
PatternGeneratorJRL::LinearConstraintInequality_s::A
Eigen::MatrixXd A
Definition: pgtypes.hh:209
PatternGeneratorJRL::COMPosition_s::y
double y[3]
Definition: pgtypes.hh:53
PatternGeneratorJRL::COMState_s
Structure to store the COM state computed by the preview control.
Definition: pgtypes.hh:75
PatternGeneratorJRL::ZMPPosition_s::pz
double pz
Definition: pgtypes.hh:119
PatternGeneratorJRL::HandAbsolutePosition_t::dddz
double dddz
Definition: pgtypes.hh:182
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::dYaw
double dYaw
Definition: pgtypes.hh:242
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::RefVectorX
Eigen::VectorXd RefVectorX
Definition: pgtypes.hh:245
PatternGeneratorJRL::FootAbsolutePosition_t::dddtheta
double dddtheta
Definition: pgtypes.hh:146
PatternGeneratorJRL::FootAbsolutePosition_t::ddtheta
double ddtheta
Definition: pgtypes.hh:144
PatternGeneratorJRL::ControlLoopOneStepArgs::finalCOMState
COMState finalCOMState
Definition: pgtypes.hh:277
PatternGeneratorJRL::ControlLoopOneStepArgs::CurrentConfiguration
Eigen::VectorXd CurrentConfiguration
Definition: pgtypes.hh:273
PatternGeneratorJRL::SupportFeet_s::SupportFoot
int SupportFoot
Definition: pgtypes.hh:229
PatternGeneratorJRL::ReferenceAbsoluteVelocity_t::RefVectorY
Eigen::VectorXd RefVectorY
Definition: pgtypes.hh:246
PatternGeneratorJRL::ControlLoopOneStepArgs::CurrentAcceleration
Eigen::VectorXd CurrentAcceleration
Definition: pgtypes.hh:275
PatternGeneratorJRL::ControlLoopOneStepArgs::ZMPTarget
Eigen::VectorXd ZMPTarget
Definition: pgtypes.hh:276
PatternGeneratorJRL::Circle_t::y_0
double y_0
Definition: pgtypes.hh:261
PatternGeneratorJRL::LinearConstraintInequalityFreeFeet_s::D
Eigen::MatrixXd D
Definition: pgtypes.hh:219
PatternGeneratorJRL::LinearConstraintInequality_s::StartingTime
double StartingTime
Definition: pgtypes.hh:213
PatternGeneratorJRL::HandAbsolutePosition_t::stepType
int stepType
Definition: pgtypes.hh:188
PatternGeneratorJRL::HandAbsolutePosition_t::time
double time
Definition: pgtypes.hh:184
PatternGeneratorJRL::LinearConstraintInequalityFreeFeet_s
Linear constraints with variable feet placement.
Definition: pgtypes.hh:218
PatternGeneratorJRL::COMPosition_s::x
double x[3]
Definition: pgtypes.hh:53