1 |
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 |
|
|
* Copyright Projet JRL-Japan, 2008 |
3 |
|
|
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 |
|
|
* |
5 |
|
|
* File: sotDynamic.h |
6 |
|
|
* Project: SOT |
7 |
|
|
* Author: Olivier Stasse |
8 |
|
|
* |
9 |
|
|
* Version control |
10 |
|
|
* =============== |
11 |
|
|
* |
12 |
|
|
* $Id$ |
13 |
|
|
* |
14 |
|
|
* Description |
15 |
|
|
* ============ |
16 |
|
|
* |
17 |
|
|
* |
18 |
|
|
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
19 |
|
|
|
20 |
|
|
#ifndef __SOT_PATTERN_GENERATOR_H__ |
21 |
|
|
#define __SOT_PATTERN_GENERATOR_H__ |
22 |
|
|
|
23 |
|
|
/* --------------------------------------------------------------------- */ |
24 |
|
|
/* --- INCLUDE --------------------------------------------------------- */ |
25 |
|
|
/* --------------------------------------------------------------------- */ |
26 |
|
|
|
27 |
|
|
/* STD */ |
28 |
|
|
#include <pinocchio/fwd.hpp> |
29 |
|
|
#include <string> |
30 |
|
|
|
31 |
|
|
/* SOT */ |
32 |
|
|
|
33 |
|
|
#include <dynamic-graph/entity.h> |
34 |
|
|
#include <dynamic-graph/pool.h> |
35 |
|
|
#include <dynamic-graph/signal-ptr.h> |
36 |
|
|
#include <dynamic-graph/signal-time-dependent.h> |
37 |
|
|
#include <sot/pattern-generator/exception-pg.h> |
38 |
|
|
|
39 |
|
|
#include <pinocchio/fwd.hpp> |
40 |
|
|
#include <sot/core/flags.hh> |
41 |
|
|
#include <sot/core/matrix-geometry.hh> |
42 |
|
|
|
43 |
|
|
/* Pattern Generator */ |
44 |
|
|
#include <jrl/walkgen/patterngeneratorinterface.hh> |
45 |
|
|
#include <jrl/walkgen/pinocchiorobot.hh> |
46 |
|
|
namespace pg = PatternGeneratorJRL; |
47 |
|
|
|
48 |
|
|
/* --------------------------------------------------------------------- */ |
49 |
|
|
/* --- API ------------------------------------------------------------- */ |
50 |
|
|
/* --------------------------------------------------------------------- */ |
51 |
|
|
|
52 |
|
|
#if defined(WIN32) |
53 |
|
|
#if defined(pg_EXPORTS) |
54 |
|
|
#define PatternGenerator_EXPORT __declspec(dllexport) |
55 |
|
|
#else |
56 |
|
|
#define PatternGenerator_EXPORT __declspec(dllimport) |
57 |
|
|
#endif |
58 |
|
|
#else |
59 |
|
|
#define PatternGenerator_EXPORT |
60 |
|
|
#endif |
61 |
|
|
|
62 |
|
|
namespace dynamicgraph { |
63 |
|
|
namespace sot { |
64 |
|
|
|
65 |
|
|
/// Define the support phase of the robot |
66 |
|
|
enum SupportPhase { |
67 |
|
|
DOUBLE_SUPPORT_PHASE = 0, |
68 |
|
|
LEFT_SUPPORT_PHASE = 1, |
69 |
|
|
RIGHT_SUPPORT_PHASE = -1, |
70 |
|
|
}; |
71 |
|
|
|
72 |
|
|
/* --------------------------------------------------------------------- */ |
73 |
|
|
/* --- CLASS ----------------------------------------------------------- */ |
74 |
|
|
/* --------------------------------------------------------------------- */ |
75 |
|
|
|
76 |
|
|
/*! @ingroup tasks |
77 |
|
|
|
78 |
|
|
\brief This class provides dynamically stable CoM, ZMP, feet trajectories. |
79 |
|
|
It wraps up the algorithms implemented by the walkGenJRL library. |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
*/ |
84 |
|
|
class PatternGenerator_EXPORT PatternGenerator : public Entity { |
85 |
|
|
public: |
86 |
|
|
// overload the new[] eigen operator |
87 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
88 |
|
|
|
89 |
|
|
/*! \name Some constant to define the type |
90 |
|
|
of frame reference. |
91 |
|
|
@{ |
92 |
|
|
*/ |
93 |
|
|
/*! \brief Specify that the frame is expressed in |
94 |
|
|
the world reference frame. */ |
95 |
|
|
static const int WORLD_FRAME = 0; |
96 |
|
|
|
97 |
|
|
/*! \brief Specify that the frame is expressed in |
98 |
|
|
the robot ego centered frame. */ |
99 |
|
|
static const int EGOCENTERED_FRAME = 1; |
100 |
|
|
|
101 |
|
|
/*! \brief Specify that the frame is expressed in |
102 |
|
|
the left foot centered frame. */ |
103 |
|
|
static const int LEFT_FOOT_CENTERED_FRAME = 2; |
104 |
|
|
|
105 |
|
|
/*! \brief Specify that the frame is expressed in |
106 |
|
|
the waist centered frame. */ |
107 |
|
|
static const int WAIST_CENTERED_FRAME = 3; |
108 |
|
|
|
109 |
|
|
/*! @} */ |
110 |
|
|
|
111 |
|
|
/*! Class name */ |
112 |
|
|
protected: |
113 |
|
|
public: |
114 |
|
|
DYNAMIC_GRAPH_ENTITY_DECL(); |
115 |
|
|
|
116 |
|
|
protected: |
117 |
|
|
/*! \brief The model of the robot. */ |
118 |
|
|
pinocchio::Model m_robotModel; |
119 |
|
|
/*! \brief Pointer towards the robot model inside jrl-walkgen. */ |
120 |
|
|
pg::PinocchioRobot *m_PR; |
121 |
|
|
/*! \brief The pointor toward the robot data. */ |
122 |
|
|
pinocchio::Data *m_robotData; |
123 |
|
|
/*! \brief Pointer towards the interface of the pattern generator. */ |
124 |
|
|
pg::PatternGeneratorInterface *m_PGI; |
125 |
|
|
|
126 |
|
|
/*! \name Fields to store name and positions of data files |
127 |
|
|
@{ |
128 |
|
|
*/ |
129 |
|
|
/*! \brief Some information related to the preview control. */ |
130 |
|
|
std::string m_PreviewControlParametersFile; |
131 |
|
|
|
132 |
|
|
/*! \brief Directory+Name where the URDF file of |
133 |
|
|
the robot's model is located. */ |
134 |
|
|
std::string m_urdfFile; |
135 |
|
|
|
136 |
|
|
/*! \brief Directory+Name where the SRDF file of |
137 |
|
|
the robot's model is located. */ |
138 |
|
|
std::string m_srdfFile; |
139 |
|
|
|
140 |
|
|
/*! \brief Directory+Name where the Rank of |
141 |
|
|
the joints are notified */ |
142 |
|
|
std::string m_xmlRankFile; |
143 |
|
|
|
144 |
|
|
std::vector<unsigned> m_wrml2urdfIndex; |
145 |
|
|
|
146 |
|
|
/*! \brief Lenght of the sole */ |
147 |
|
|
double m_soleLength; |
148 |
|
|
|
149 |
|
|
/*! \brief Width of the sole */ |
150 |
|
|
double m_soleWidth; |
151 |
|
|
|
152 |
|
|
/* \brief Special joints map for the parser */ |
153 |
|
|
std::map<std::string, std::string> specialJoints_; |
154 |
|
|
|
155 |
|
|
/*! @} */ |
156 |
|
|
|
157 |
|
|
/*! \brief Boolean variable to initialize the object |
158 |
|
|
by loading an object. */ |
159 |
|
|
bool m_init; |
160 |
|
|
|
161 |
|
|
/*! \brief Boolean variable to initialize the position: |
162 |
|
|
first through the real state of the robot, |
163 |
|
|
then through the motor command. */ |
164 |
|
|
bool m_InitPositionByRealState; |
165 |
|
|
|
166 |
|
|
/*! \brief Integer for the support foot. */ |
167 |
|
|
int m_SupportFoot; |
168 |
|
|
|
169 |
|
|
/*! \brief Keep the frame reference */ |
170 |
|
|
int m_ReferenceFrame; |
171 |
|
|
|
172 |
|
|
/*! \brief Distance between ankle and soil */ |
173 |
|
|
double m_AnkleSoilDistance; |
174 |
|
|
|
175 |
|
|
/*! \brief Time step */ |
176 |
|
|
double m_TimeStep; |
177 |
|
|
|
178 |
|
|
/*! \brief Current support/contact phase defined by enum: leftFoot=1, |
179 |
|
|
* rightFoot=-1, doubleSupport=0. */ |
180 |
|
|
SupportPhase m_ContactPhase; |
181 |
|
|
int m_DSStartingTime; |
182 |
|
|
|
183 |
|
|
/*! \brief iteration time. */ |
184 |
|
|
int m_LocalTime; |
185 |
|
|
|
186 |
|
|
/*! \brief count for subsampling. */ |
187 |
|
|
unsigned int m_count; |
188 |
|
|
|
189 |
|
|
/* \name Body names of the end effectors |
190 |
|
|
@{ */ |
191 |
|
|
/* \brief Left ankle */ |
192 |
|
|
std::string m_left_ankle_body_name; |
193 |
|
|
|
194 |
|
|
/* \brief Right ankle */ |
195 |
|
|
std::string m_right_ankle_body_name; |
196 |
|
|
|
197 |
|
|
/* \brief Left wrist */ |
198 |
|
|
std::string m_left_wrist_body_name; |
199 |
|
|
|
200 |
|
|
/* \brief Right wrist */ |
201 |
|
|
std::string m_right_wrist_body_name; |
202 |
|
|
|
203 |
|
|
/* @} */ |
204 |
|
|
public: /* --- CONSTRUCTION --- */ |
205 |
|
|
/*! \brief Default constructor. */ |
206 |
|
|
PatternGenerator(const std::string &name = "PatternGenerator"); |
207 |
|
|
/*! \brief Default destructor. */ |
208 |
|
|
virtual ~PatternGenerator(void); |
209 |
|
|
|
210 |
|
|
public: /* --- MODEL CREATION --- */ |
211 |
|
|
/*! \name Methods related to the data files. |
212 |
|
|
@{ |
213 |
|
|
*/ |
214 |
|
|
|
215 |
|
|
/*! \brief Build the pattern generator interface from the parameter |
216 |
|
|
"/robot_description" and the informations in |
217 |
|
|
"/robot/specifificities/feet/[right|left]/[size|anklePosition]*/ |
218 |
|
|
bool buildPGI(void); |
219 |
|
|
|
220 |
|
|
/*! \brief Add complementary frame. */ |
221 |
|
|
bool addComplementaryFrames(); |
222 |
|
|
|
223 |
|
|
/*! \brief Build the reduced model. */ |
224 |
|
|
bool buildReducedModel(void); |
225 |
|
|
|
226 |
|
|
/*! \brief readFootParameters */ |
227 |
|
|
void readFootParameters(std::string &rootFootPath, pg::PRFoot &aFoot); |
228 |
|
|
|
229 |
|
|
/*! \brief Initialize the state of the robot. */ |
230 |
|
|
bool InitState(void); |
231 |
|
|
|
232 |
|
|
/*! \brief Set the directory which contains the parameters |
233 |
|
|
for the preview control. */ |
234 |
|
|
void setPreviewControlParametersFile(const std::string &filename); |
235 |
|
|
|
236 |
|
|
/*! \brief Set the path which contains the URDF files robot's model. */ |
237 |
|
|
void setURDFFile(const std::string &filename); |
238 |
|
|
|
239 |
|
|
/*! \brief Set the path which contains the SRDF files robot's model. |
240 |
|
|
More precisely this file describes which joints are the hands, feet. |
241 |
|
|
For more information please see the documentation of walkGenJRL. |
242 |
|
|
*/ |
243 |
|
|
void setSRDFFile(const std::string &filename); |
244 |
|
|
|
245 |
|
|
/*! \brief Set the path which contains the Joint Rank model. */ |
246 |
|
|
void setXmlRankFile(const std::string &filename); |
247 |
|
|
|
248 |
|
|
/*! \brief Set the name of the file specifying the control parameters |
249 |
|
|
of the preview control. */ |
250 |
|
|
void setParamPreviewFile(const std::string &filename); |
251 |
|
|
|
252 |
|
|
/*! \brief Set the foot parameters */ |
253 |
|
|
void setSoleParameters(const double &inSoleLength, const double &inSoleWidth); |
254 |
|
|
|
255 |
|
|
/*! \brief Set mapping between a link and actual robot name */ |
256 |
|
|
void addJointMapping(const std::string &link, const std::string &repName); |
257 |
|
|
|
258 |
|
|
/*! \brief Give access directly to the pattern generator... |
259 |
|
|
You really have to know what your are doing. */ |
260 |
|
|
pg::PatternGeneratorInterface *GetPatternGeneratorInterface() { |
261 |
|
|
return m_PGI; |
262 |
|
|
}; |
263 |
|
|
|
264 |
|
|
/*! @} */ |
265 |
|
|
|
266 |
|
|
public: /* --- SIGNALS --- */ |
267 |
|
|
typedef int Dummy; |
268 |
|
|
|
269 |
|
|
/*! \name Internal signals. |
270 |
|
|
@{ |
271 |
|
|
*/ |
272 |
|
|
|
273 |
|
|
/*! \brief Internal signal for initialization and one shot signals. */ |
274 |
|
|
SignalTimeDependent<Dummy, int> firstSINTERN; |
275 |
|
|
|
276 |
|
|
/*! \brief Internal signal to trigger one step of the algorithm. */ |
277 |
|
|
SignalTimeDependent<Dummy, int> OneStepOfControlS; |
278 |
|
|
|
279 |
|
|
/*! @} */ |
280 |
|
|
|
281 |
|
|
protected: |
282 |
|
|
/*! \name Internal methods to access reference trajectories. |
283 |
|
|
@{ |
284 |
|
|
*/ |
285 |
|
|
/*! \brief Internal method to get the reference ZMP at a given time. */ |
286 |
|
|
dynamicgraph::Vector &getZMPRef(dynamicgraph::Vector &res, int time); |
287 |
|
|
|
288 |
|
|
/*! \brief Internal method to get the reference CoM at a given time.*/ |
289 |
|
|
dynamicgraph::Vector &getCoMRef(dynamicgraph::Vector &res, int time); |
290 |
|
|
|
291 |
|
|
/*! \brief Internal method to get the reference dCoM at a given time.*/ |
292 |
|
|
dynamicgraph::Vector &getdCoMRef(dynamicgraph::Vector &res, int time); |
293 |
|
|
|
294 |
|
|
/*! \brief Internal method to get the reference ddCoM at a given time.*/ |
295 |
|
|
dynamicgraph::Vector &getddCoMRef(dynamicgraph::Vector &res, int time); |
296 |
|
|
|
297 |
|
|
/*! \brief Internal method to get the external forces at a given time.*/ |
298 |
|
|
dynamicgraph::Vector &getExternalForces(dynamicgraph::Vector &forces, |
299 |
|
|
int time); |
300 |
|
|
|
301 |
|
|
/*! \brief Internal method to get the position of the left foot. */ |
302 |
|
|
MatrixHomogeneous &getLeftFootRef(MatrixHomogeneous &res, int time); |
303 |
|
|
|
304 |
|
|
/*! \brief Internal method to get the position of the right foot. */ |
305 |
|
|
MatrixHomogeneous &getRightFootRef(MatrixHomogeneous &res, int time); |
306 |
|
|
|
307 |
|
|
/*! \brief Internal method to get the derivative of the left foot. */ |
308 |
|
|
MatrixHomogeneous &getdotLeftFootRef(MatrixHomogeneous &res, int time); |
309 |
|
|
|
310 |
|
|
/*! \brief Internal method to get the derivative of the right foot. */ |
311 |
|
|
MatrixHomogeneous &getdotRightFootRef(MatrixHomogeneous &res, int time); |
312 |
|
|
|
313 |
|
|
/*! \brief Internal method to get the position of the flying foot. */ |
314 |
|
|
MatrixHomogeneous &getFlyingFootRef(MatrixHomogeneous &res, int time); |
315 |
|
|
|
316 |
|
|
/*! \brief Internal method to get the joint position for walking. */ |
317 |
|
|
dynamicgraph::Vector &getjointWalkingErrorPosition(dynamicgraph::Vector &res, |
318 |
|
|
int time); |
319 |
|
|
|
320 |
|
|
/*! \brief Internal method to get the derivative of the com attitude. */ |
321 |
|
|
dynamicgraph::Vector &getdComAttitude(dynamicgraph::Vector &res, int time); |
322 |
|
|
|
323 |
|
|
/*! \brief Internal method to get the second derivative of the com attitude. |
324 |
|
|
*/ |
325 |
|
|
dynamicgraph::Vector &getddComAttitude(dynamicgraph::Vector &res, int time); |
326 |
|
|
|
327 |
|
|
/*! \brief Internal method to get the attitude of the com. */ |
328 |
|
|
dynamicgraph::Vector &getComAttitude(dynamicgraph::Vector &res, int time); |
329 |
|
|
|
330 |
|
|
/*! \brief Internal method to get the attitude of the waist. */ |
331 |
|
|
VectorRollPitchYaw &getWaistAttitude(VectorRollPitchYaw &res, int time); |
332 |
|
|
|
333 |
|
|
/*! \brief Internal method to get the absolute attitude of the waist. */ |
334 |
|
|
VectorRollPitchYaw &getWaistAttitudeAbsolute(VectorRollPitchYaw &res, |
335 |
|
|
int time); |
336 |
|
|
|
337 |
|
|
/*! \brief Internal method to get the absolute attitude of the waist into |
338 |
|
|
an homogeneous matrix. */ |
339 |
|
|
MatrixHomogeneous &getWaistAttitudeMatrixAbsolute(MatrixHomogeneous &res, |
340 |
|
|
int time); |
341 |
|
|
|
342 |
|
|
/*! \brief Internal method to get the dataInPorcess flag */ |
343 |
|
|
unsigned &getDataInProcess(unsigned &res, int time); |
344 |
|
|
|
345 |
|
|
/*! \brief Internal method to get the position of the waist. */ |
346 |
|
|
dynamicgraph::Vector &getWaistPosition(dynamicgraph::Vector &res, int time); |
347 |
|
|
|
348 |
|
|
/*! \brief Internal method to get the absolute position of the waist. */ |
349 |
|
|
dynamicgraph::Vector &getWaistPositionAbsolute(dynamicgraph::Vector &res, |
350 |
|
|
int time); |
351 |
|
|
|
352 |
|
|
/*! @} */ |
353 |
|
|
|
354 |
|
|
/*! \brief Getting the current support foot: 1 Left -1 Right. */ |
355 |
|
|
int &getSupportFoot(int &res, int time); |
356 |
|
|
|
357 |
|
|
/*! \brief Trigger the initialization of the algorithm */ |
358 |
|
|
int &InitOneStepOfControl(int &dummy, int time); |
359 |
|
|
/*! \brief Trigger one step of the algorithm. */ |
360 |
|
|
int &OneStepOfControl(int &dummy, int time); |
361 |
|
|
|
362 |
|
|
/*! \name Keep information computed once for each time. |
363 |
|
|
@{ |
364 |
|
|
*/ |
365 |
|
|
|
366 |
|
|
/*! \brief Rigit motion between two waist positions |
367 |
|
|
at the beginning of the walking and at the end of the walking. */ |
368 |
|
|
MatrixHomogeneous m_k_Waist_kp1; |
369 |
|
|
|
370 |
|
|
/*! \brief Absolute Position for the left and right feet. */ |
371 |
|
|
MatrixHomogeneous m_LeftFootPosition, m_RightFootPosition; |
372 |
|
|
PatternGeneratorJRL::FootAbsolutePosition m_PrevSamplingRightFootAbsPos, |
373 |
|
|
m_PrevSamplingLeftFootAbsPos; |
374 |
|
|
PatternGeneratorJRL::FootAbsolutePosition m_NextSamplingRightFootAbsPos, |
375 |
|
|
m_NextSamplingLeftFootAbsPos; |
376 |
|
|
PatternGeneratorJRL::FootAbsolutePosition m_InitRightFootAbsPos, |
377 |
|
|
m_InitLeftFootAbsPos; |
378 |
|
|
|
379 |
|
|
/*! \brief Absolute Derivate for the left and right feet. */ |
380 |
|
|
MatrixHomogeneous m_dotLeftFootPosition, m_dotRightFootPosition; |
381 |
|
|
|
382 |
|
|
/*! \brief Initial Absolute Starting Position |
383 |
|
|
for the left and right feet. */ |
384 |
|
|
MatrixHomogeneous m_InitLeftFootPosition, m_InitRightFootPosition; |
385 |
|
|
|
386 |
|
|
/*! \brief Keep track of the motion between sequence of motions. */ |
387 |
|
|
MatrixHomogeneous m_MotionSinceInstanciationToThisSequence; |
388 |
|
|
|
389 |
|
|
/*! \brief Relative Position of the flying foot. */ |
390 |
|
|
MatrixHomogeneous m_FlyingFootPosition; |
391 |
|
|
|
392 |
|
|
/*! \brief Absolute position of the reference ZMP. */ |
393 |
|
|
dynamicgraph::Vector m_ZMPRefPos; |
394 |
|
|
|
395 |
|
|
/*! \brief Com Attitude: does not really exist apart |
396 |
|
|
from when the robot |
397 |
|
|
is seen as an inverted pendulum*/ |
398 |
|
|
dynamicgraph::Vector m_ComAttitude; |
399 |
|
|
|
400 |
|
|
/*! \brief dCom Attitude: does not really exist apart when the robot |
401 |
|
|
is seen as an inverted pendulum*/ |
402 |
|
|
dynamicgraph::Vector m_dComAttitude; |
403 |
|
|
|
404 |
|
|
/*! \brief ddCom Attitude: does not really exist apart when the robot |
405 |
|
|
is seen as an inverted pendulum*/ |
406 |
|
|
dynamicgraph::Vector m_ddComAttitude; |
407 |
|
|
|
408 |
|
|
/*! \brief Absolute position of the reference CoM. */ |
409 |
|
|
dynamicgraph::Vector m_COMRefPos; |
410 |
|
|
dynamicgraph::Vector m_PrevSamplingCOMRefPos; |
411 |
|
|
dynamicgraph::Vector m_NextSamplingCOMRefPos; |
412 |
|
|
|
413 |
|
|
/*! \brief Absolute position of the reference dCoM. */ |
414 |
|
|
dynamicgraph::Vector m_dCOMRefPos; |
415 |
|
|
dynamicgraph::Vector m_PrevSamplingdCOMRefPos; |
416 |
|
|
dynamicgraph::Vector m_NextSamplingdCOMRefPos; |
417 |
|
|
|
418 |
|
|
/*! \brief Absolute position of the reference ddCoM. */ |
419 |
|
|
dynamicgraph::Vector m_ddCOMRefPos; |
420 |
|
|
dynamicgraph::Vector m_PrevSamplingddCOMRefPos; |
421 |
|
|
dynamicgraph::Vector m_NextSamplingddCOMRefPos; |
422 |
|
|
|
423 |
|
|
/*! \brief Initial Absolute position of the reference ZMP. */ |
424 |
|
|
dynamicgraph::Vector m_InitZMPRefPos; |
425 |
|
|
|
426 |
|
|
/*! \brief Initial Absolute position and |
427 |
|
|
attitude of the reference Waist. */ |
428 |
|
|
dynamicgraph::Vector m_InitWaistRefPos, m_InitWaistRefAtt; |
429 |
|
|
|
430 |
|
|
/*! \brief Initial Absolute position of the reference CoM. */ |
431 |
|
|
dynamicgraph::Vector m_InitCOMRefPos; |
432 |
|
|
|
433 |
|
|
/*! \brief Waist position */ |
434 |
|
|
dynamicgraph::Vector m_WaistPosition; |
435 |
|
|
|
436 |
|
|
/*! \brief Waist position Absolute */ |
437 |
|
|
dynamicgraph::Vector m_WaistPositionAbsolute; |
438 |
|
|
|
439 |
|
|
/*! \brief Waist Attitude */ |
440 |
|
|
dynamicgraph::Vector m_WaistAttitude; |
441 |
|
|
|
442 |
|
|
/*! \brief Waist Attitude Absolute */ |
443 |
|
|
dynamicgraph::Vector m_WaistAttitudeAbsolute; |
444 |
|
|
dynamicgraph::Vector m_PrevSamplingWaistAttAbs; |
445 |
|
|
dynamicgraph::Vector m_NextSamplingWaistAttAbs; |
446 |
|
|
|
447 |
|
|
/*! \brief Waist Attitude Homogeneous Matrix */ |
448 |
|
|
MatrixHomogeneous m_WaistAttitudeMatrixAbsolute; |
449 |
|
|
|
450 |
|
|
/*! \brief Joint values for walking. */ |
451 |
|
|
dynamicgraph::Vector m_JointErrorValuesForWalking; |
452 |
|
|
|
453 |
|
|
/*! \brief Velocity reference for Herdt's PG */ |
454 |
|
|
dynamicgraph::Vector m_VelocityReference; |
455 |
|
|
|
456 |
|
|
/*! \brief trigger to start walking */ |
457 |
|
|
bool m_trigger; |
458 |
|
|
|
459 |
|
|
/*! \brief true iff the pattern if dealing with data, |
460 |
|
|
false if pg is not |
461 |
|
|
* working anymore/yet. */ |
462 |
|
|
unsigned int m_dataInProcess; |
463 |
|
|
|
464 |
|
|
/*! \brief Booleans used to indicate if feedback |
465 |
|
|
signals shoul be used or not */ |
466 |
|
|
bool m_feedBackControl; |
467 |
|
|
|
468 |
|
|
/*! \brief Booleans used to indicate if force |
469 |
|
|
feedback signals shoul be used or not */ |
470 |
|
|
bool m_forceFeedBack; |
471 |
|
|
|
472 |
|
|
/*! \brief Booleans used to indicate feet contacts */ |
473 |
|
|
bool m_rightFootContact, m_leftFootContact; |
474 |
|
|
|
475 |
|
|
/*! @} */ |
476 |
|
|
|
477 |
|
|
/*! Parsing a file of command by the walking |
478 |
|
|
pattern generator interface. |
479 |
|
|
\par[in] The command line (optional option) |
480 |
|
|
\par[in] */ |
481 |
|
|
void ParseCmdFile(std::istringstream &cmdArg, std::ostream &os); |
482 |
|
|
|
483 |
|
|
/*! \brief Transfert from a current absolute foot position |
484 |
|
|
to a dot homogeneous matrix. */ |
485 |
|
|
void FromAbsoluteFootPosToDotHomogeneous( |
486 |
|
|
pg::FootAbsolutePosition aFootPosition, MatrixHomogeneous &aFootMH, |
487 |
|
|
MatrixHomogeneous &adotFootMH); |
488 |
|
|
|
489 |
|
|
/*! \brief Transfert from a current absolute foot position |
490 |
|
|
to a homogeneous matrix. */ |
491 |
|
|
void FromAbsoluteFootPosToHomogeneous(pg::FootAbsolutePosition aFootPosition, |
492 |
|
|
MatrixHomogeneous &aFootMH); |
493 |
|
|
|
494 |
|
|
/*! \brief Provide an homogeneous matrix |
495 |
|
|
from the current waist position and attitude*/ |
496 |
|
|
void getAbsoluteWaistPosAttHomogeneousMatrix(MatrixHomogeneous &aWaistMH); |
497 |
|
|
|
498 |
|
|
void SubsamplingFootPos(pg::FootAbsolutePosition &PrevFootPosition, |
499 |
|
|
pg::FootAbsolutePosition &NextFootPosition, |
500 |
|
|
MatrixHomogeneous &FootPositionOut, |
501 |
|
|
MatrixHomogeneous &dotFootPositionOut, |
502 |
|
|
unsigned int &count); |
503 |
|
|
|
504 |
|
|
void SubsamplingVector(dynamicgraph::Vector &PrevPosition, |
505 |
|
|
dynamicgraph::Vector &NextPosition, |
506 |
|
|
dynamicgraph::Vector &PositionOut, |
507 |
|
|
unsigned int &count); |
508 |
|
|
|
509 |
|
|
void CopyFootPosition(pg::FootAbsolutePosition &FootPositionIn, |
510 |
|
|
pg::FootAbsolutePosition &FootPositionOut); |
511 |
|
|
|
512 |
|
|
/*! \brief Internal method to get the initial |
513 |
|
|
reference ZMP at a given time. */ |
514 |
|
|
dynamicgraph::Vector &getInitZMPRef(dynamicgraph::Vector &res, int time); |
515 |
|
|
|
516 |
|
|
/*! \brief Internal method to get the |
517 |
|
|
initial reference CoM at a given time.*/ |
518 |
|
|
dynamicgraph::Vector &getInitCoMRef(dynamicgraph::Vector &res, int time); |
519 |
|
|
|
520 |
|
|
/*! \brief Internal method to get the initial |
521 |
|
|
reference CoM at a given time.*/ |
522 |
|
|
dynamicgraph::Vector &getInitWaistPosRef(dynamicgraph::Vector &res, int time); |
523 |
|
|
|
524 |
|
|
/*! \brief Internal method to get the initial |
525 |
|
|
reference CoM at a given time.*/ |
526 |
|
|
VectorRollPitchYaw &getInitWaistAttRef(VectorRollPitchYaw &res, int time); |
527 |
|
|
|
528 |
|
|
/*! \brief Internal method to get the position of the left foot. */ |
529 |
|
|
MatrixHomogeneous &getInitLeftFootRef(MatrixHomogeneous &res, int time); |
530 |
|
|
|
531 |
|
|
/*! \brief Internal method to get the position of the right foot. */ |
532 |
|
|
MatrixHomogeneous &getInitRightFootRef(MatrixHomogeneous &res, int time); |
533 |
|
|
|
534 |
|
|
/*! \brief Internal method to get the information of contact or not on |
535 |
|
|
the feet. */ |
536 |
|
|
bool &getLeftFootContact(bool &res, int time); |
537 |
|
|
bool &getRightFootContact(bool &res, int time); |
538 |
|
|
/*! \brief Internal method to get the information of contact phase leftFoot=1, |
539 |
|
|
* rightFoot=-1, doubleSupport=0. */ |
540 |
|
|
int &getContactPhase(int &res, int time); |
541 |
|
|
|
542 |
|
|
public: |
543 |
|
|
/*! \name External signals |
544 |
|
|
@{ */ |
545 |
|
|
/*! \brief Real state position values. */ |
546 |
|
|
SignalPtr<dynamicgraph::Vector, int> jointPositionSIN; |
547 |
|
|
|
548 |
|
|
/*! \brief Motor control joint position values. */ |
549 |
|
|
SignalPtr<dynamicgraph::Vector, int> motorControlJointPositionSIN; |
550 |
|
|
|
551 |
|
|
/*! \brief Previous ZMP value (ZMP send by the preceding controller). */ |
552 |
|
|
SignalPtr<dynamicgraph::Vector, int> ZMPPreviousControllerSIN; |
553 |
|
|
|
554 |
|
|
/*! \brief Externalize the ZMP reference . */ |
555 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> ZMPRefSOUT; |
556 |
|
|
|
557 |
|
|
/*! \brief Externalize the CoM reference. */ |
558 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> CoMRefSOUT; |
559 |
|
|
|
560 |
|
|
/*! \brief Externalize the CoM reference. */ |
561 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> dCoMRefSOUT; |
562 |
|
|
|
563 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> ddCoMRefSOUT; |
564 |
|
|
/*! \brief Take the current CoM. */ |
565 |
|
|
SignalPtr<dynamicgraph::Vector, int> comSIN; |
566 |
|
|
|
567 |
|
|
/*! \brief Take the current CoM state (pos, vel, acc). */ |
568 |
|
|
SignalPtr<dynamicgraph::Vector, int> comStateSIN; |
569 |
|
|
|
570 |
|
|
/*! \brief Take the current zmp (x, y, z). */ |
571 |
|
|
SignalPtr<dynamicgraph::Vector, int> zmpSIN; |
572 |
|
|
|
573 |
|
|
/*! \brief Take the current external force applied |
574 |
|
|
to the com (fx, fy, fz). */ |
575 |
|
|
SignalPtr<dynamicgraph::Vector, int> forceSIN; |
576 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> forceSOUT; |
577 |
|
|
dynamicgraph::Vector m_initForce; |
578 |
|
|
dynamicgraph::Vector m_currentForces; |
579 |
|
|
std::deque<dynamicgraph::Vector> m_bufferForce; |
580 |
|
|
std::vector<double> m_filterWindow; |
581 |
|
|
|
582 |
|
|
/*! \brief Take the current desired velocity. */ |
583 |
|
|
SignalPtr<dynamicgraph::Vector, int> velocitydesSIN; |
584 |
|
|
|
585 |
|
|
/*! \brief Take the current trigger to start OneStepOfControl. */ |
586 |
|
|
SignalPtr<bool, int> triggerSIN; |
587 |
|
|
|
588 |
|
|
/*! \brief Take the current left foot homogeneous position. */ |
589 |
|
|
SignalPtr<MatrixHomogeneous, int> LeftFootCurrentPosSIN; |
590 |
|
|
|
591 |
|
|
/*! \brief Take the current right foot homogeneous position. */ |
592 |
|
|
SignalPtr<MatrixHomogeneous, int> RightFootCurrentPosSIN; |
593 |
|
|
|
594 |
|
|
/*! \brief Externalize the left foot position reference. */ |
595 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> LeftFootRefSOUT; |
596 |
|
|
|
597 |
|
|
/*! \brief Externalize the right foot position reference. */ |
598 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> RightFootRefSOUT; |
599 |
|
|
|
600 |
|
|
/*! \brief Externalize the left foot position reference. */ |
601 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> dotLeftFootRefSOUT; |
602 |
|
|
|
603 |
|
|
/*! \brief Externalize the right foot position reference. */ |
604 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> dotRightFootRefSOUT; |
605 |
|
|
|
606 |
|
|
/*! \brief Externalize the foot which is not considered as support foot, |
607 |
|
|
the information are given in a relative referentiel. */ |
608 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> FlyingFootRefSOUT; |
609 |
|
|
|
610 |
|
|
/*! \brief Externalize the support foot. */ |
611 |
|
|
SignalTimeDependent<int, int> SupportFootSOUT; |
612 |
|
|
|
613 |
|
|
/*! \brief Externalize the joint values for walking. */ |
614 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> jointWalkingErrorPositionSOUT; |
615 |
|
|
|
616 |
|
|
/*! \brief Externalize the com attitude. */ |
617 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> comattitudeSOUT; |
618 |
|
|
|
619 |
|
|
/*! \brief Externalize the dcom attitude. */ |
620 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> dcomattitudeSOUT; |
621 |
|
|
|
622 |
|
|
/*! \brief Externalize the ddcom attitude. */ |
623 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> ddcomattitudeSOUT; |
624 |
|
|
|
625 |
|
|
/*! \brief Externalize the waist attitude. */ |
626 |
|
|
SignalTimeDependent<VectorRollPitchYaw, int> waistattitudeSOUT; |
627 |
|
|
|
628 |
|
|
/*! \brief Externalize the absolute waist attitude. */ |
629 |
|
|
SignalTimeDependent<VectorRollPitchYaw, int> waistattitudeabsoluteSOUT; |
630 |
|
|
|
631 |
|
|
/*! \brief Externalize the absolute waist attitude into a homogeneous matrix. |
632 |
|
|
*/ |
633 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> waistattitudematrixabsoluteSOUT; |
634 |
|
|
|
635 |
|
|
/*! \brief Externalize the waist position. */ |
636 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> waistpositionSOUT; |
637 |
|
|
|
638 |
|
|
/*! \brief Externalize the absolute waist position. */ |
639 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> waistpositionabsoluteSOUT; |
640 |
|
|
|
641 |
|
|
/*! \brief true iff PG is processing. Use it for synchronize. */ |
642 |
|
|
SignalTimeDependent<unsigned int, int> dataInProcessSOUT; |
643 |
|
|
|
644 |
|
|
/*! \brief Externalize the initial ZMP reference . */ |
645 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> InitZMPRefSOUT; |
646 |
|
|
|
647 |
|
|
/*! \brief Externalize the initial CoM reference. */ |
648 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> InitCoMRefSOUT; |
649 |
|
|
|
650 |
|
|
/*! \brief Externalize the initial Waist reference. */ |
651 |
|
|
SignalTimeDependent<dynamicgraph::Vector, int> InitWaistPosRefSOUT; |
652 |
|
|
|
653 |
|
|
/*! \brief Externalize the initial Waist reference. */ |
654 |
|
|
SignalTimeDependent<VectorRollPitchYaw, int> InitWaistAttRefSOUT; |
655 |
|
|
|
656 |
|
|
/*! \brief Externalize the left foot position reference. */ |
657 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> InitLeftFootRefSOUT; |
658 |
|
|
|
659 |
|
|
/*! \brief Externalize the right foot position reference. */ |
660 |
|
|
SignalTimeDependent<MatrixHomogeneous, int> InitRightFootRefSOUT; |
661 |
|
|
|
662 |
|
|
/*! \brief Booleans for contact of the feet */ |
663 |
|
|
SignalTimeDependent<bool, int> leftFootContactSOUT; |
664 |
|
|
SignalTimeDependent<bool, int> rightFootContactSOUT; |
665 |
|
|
/*! @} */ |
666 |
|
|
|
667 |
|
|
/*! \brief Int Vector of support phase: leftFoot=1, rightFoot=-1, |
668 |
|
|
* doubleSupport=0 (see enum). */ |
669 |
|
|
SignalTimeDependent<int, int> contactPhaseSOUT; |
670 |
|
|
|
671 |
|
|
/*! \name Reimplement the interface of the plugin. |
672 |
|
|
@{ */ |
673 |
|
|
|
674 |
|
|
/*! @} */ |
675 |
|
|
protected: |
676 |
|
|
/*! Storing the previous ZMP value. */ |
677 |
|
|
Eigen::VectorXd m_ZMPPrevious; |
678 |
|
|
|
679 |
|
|
public: /* --- PARAMS --- */ |
680 |
|
|
void initCommands(void); |
681 |
|
|
int stringToReferenceEnum(const std::string &FrameReference); |
682 |
|
|
void setReferenceFromString(const std::string &str); |
683 |
|
|
void addOnLineStep(const double &x, const double &y, const double &th); |
684 |
|
|
void addStep(const double &x, const double &y, const double &th); |
685 |
|
|
void pgCommandLine(const std::string &cmdline); |
686 |
|
|
void useFeedBackSignals(const bool &feedBack); |
687 |
|
|
void useDynamicFilter(const bool &dynamicFilter); |
688 |
|
|
|
689 |
|
|
void debug(void); |
690 |
|
|
}; |
691 |
|
|
|
692 |
|
|
} // namespace sot |
693 |
|
|
} // namespace dynamicgraph |
694 |
|
|
|
695 |
|
|
#endif // #ifndef __SOT_PATTERN_GENERATOR_H__ |