humoto
mpc_wpg.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Don Joven Agravante
5  @author Jan Michalczyk
6  @copyright 2014-2017 INRIA, 2014-2015 CNRS. Licensed under the Apache
7  License, Version 2.0. (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
8  @brief
9 */
10 
11 #pragma once
12 
13 namespace humoto
14 {
15  namespace wpg04
16  {
17  /**
18  * @brief Model Predictive Control problem for walking pattern generation [determine_solution_structure.m,
19  * form_rotation_matrices.m, form_foot_pos_matrices.m, form_condensing_matrices.m]
20  */
22  {
23  private:
26 
27 
28  private:
29  /**
30  * @brief Create the rotation matrices of the MPC problem
31  */
33  {
34  R_.setZero(preview_horizon_.getNumberOfVariableSteps());
35  Rh_.setZero(preview_horizon_.intervals_.size());
36 
37  std::size_t index = 0;
38  for(std::size_t i=0; i < (preview_horizon_.walk_states_.size() - 1); ++i)
39  {
40  if (humoto::walking::StanceType::TDS != preview_horizon_.walk_states_[i].type_)
41  {
42  // orientations of the preceding foot positions.
43  R_(index) = preview_horizon_.walk_states_.at(i).rotation_;
44  ++index;
45  }
46  }
47 
48 
49  for(std::size_t i=0; i < preview_horizon_.intervals_.size(); ++i)
50  {
51  Rh_(i) = preview_horizon_.getRotationMatrix(i);
52  }
53  }
54 
55 
56  /**
57  * @brief Create the foot position matrices
58  *
59  * @param[in] model
60  */
62  {
63  // generate_fixed_step_vector
64  V0_ = model.current_support_position_.replicate(preview_horizon_.intervals_.size(), 1);
65 
66 
67  Ir_.setZero(preview_horizon_.intervals_.size(), preview_horizon_.getNumberOfVariableSteps());
68 
69  for(std::size_t i=0; i < preview_horizon_.variable_steps_indices_.size(); ++i)
70  {
71  EigenIndex row_size = preview_horizon_.intervals_.size() - preview_horizon_.variable_steps_indices_[i];
72  Ir_.block(preview_horizon_.variable_steps_indices_[i], i, row_size, 1).setConstant(1);
73  }
74 
76 
77  V_ = Ir_bmi * R_;
78 
79  Vfp_.noalias() = Eigen::Matrix2d::Identity().replicate(
80  preview_horizon_.getNumberOfVariableSteps(),
81  preview_horizon_.getNumberOfVariableSteps()).triangularView<Eigen::Lower>() * R_.getRaw();
82 
83  vfp_ = model.current_support_position_.replicate(preview_horizon_.getNumberOfVariableSteps(), 1);
84  }
85 
86 
87  /**
88  * @brief Initialize next model state
89  *
90  * @param[in] stance_fsm walking finite state machine (must be updated before)
91  * @param[in] model model
92  *
93  * @return next model state.
94  */
97  const humoto::wpg04::Model &model) const
98  {
99  humoto::wpg04::ModelState model_state;
100 
101  double T = preview_horizon_.intervals_[0].T_;
102  double Ts = mpc_parameters_.getSubsamplingTime();
103  double com_height = preview_horizon_.intervals_[0].com_height_;
104 
105 
106  model_state.com_state_ = model.evaluate(Ts,
107  T,
108  com_height,
109  model.getCState(),
110  cop_profile.segment(0, model.Nu_));
111 
112  model_state.stance_type_ = stance_fsm.current_stance_.type_;
113 
114  model_state.next_stance_type_ = (stance_fsm.getNextStance()).type_;
115 
116 
117  switch(model_state.stance_type_) // new
118  {
120  model_state.feet_.getRight().unset();
121  model_state.feet_.setLeft(model.getFootState(LeftOrRight::LEFT));
122  break;
123 
125  model_state.feet_.getLeft().unset();
126  model_state.feet_.setRight(model.getFootState(LeftOrRight::RIGHT));
127  break;
128 
131  {
132  LeftOrRight::Type landing_foot;
133  LeftOrRight::Type support_foot;
134  switch (model.state_.stance_type_) // old
135  {
137  landing_foot = humoto::LeftOrRight::RIGHT;
138  break;
140  landing_foot = humoto::LeftOrRight::LEFT;
141  break;
142  default:
143  HUMOTO_THROW_MSG("Unknown state type.");
144  break;
145  }
146  support_foot = humoto::LeftOrRight::invert(landing_foot);
147 
148  getFootLandingState(model_state.feet_[landing_foot], model, landing_foot);
149  model_state.feet_[support_foot] = model.getFootState(support_foot);
150  }
151  else
152  {
153  model_state.feet_.setLeft(model.getFootState(LeftOrRight::LEFT));
154  model_state.feet_.setRight(model.getFootState(LeftOrRight::RIGHT));
155  }
156  break;
157 
159  model_state.feet_.setLeft(model.getFootState(LeftOrRight::LEFT));
160  model_state.feet_.setRight(model.getFootState(LeftOrRight::RIGHT));
161  break;
162 
163  default:
164  HUMOTO_THROW_MSG("Unknown stance type.");
165  break;
166  }
167 
168 
169  return(model_state);
170  }
171 
172 
173 
174  /**
175  * @brief Determine landing state of a foot
176  *
177  * @param[out] foot_state state of the landing foot
178  * @param[in] model model
179  * @param[in] landing_foot left or right
180  */
182  const humoto::wpg04::Model &model,
183  const humoto::LeftOrRight::Type landing_foot) const
184  {
185  std::size_t interval_index = preview_horizon_.variable_steps_indices_[0];
186  const WalkState & walk_state = preview_horizon_.getWalkState(interval_index);
187 
188 
189  foot_state.setDefaults();
190  etools::Vector2 position_xy;
191 
192  humoto::LeftOrRight::Type support_foot = LeftOrRight::invert(landing_foot);
193 
194 
195  switch (walk_state.type_) // next stance
196  {
199  position_xy = footpos_profile.segment(0, 2);
200  break;
201 
205  {
206  position_xy = model.getFootPositionFromADS( landing_foot,
207  walk_state.rotation_,
208  footpos_profile.segment(0, 2));
209  }
210  else
211  {
212  HUMOTO_THROW_MSG("Double support cannot be followed by another double support.");
213  }
214  break;
215 
216  default:
217  HUMOTO_THROW_MSG("Transitional double support cannot have variable position.");
218  break;
219  }
220  double position_z = model.getFootState(support_foot).position_.z();
221  foot_state.position_ << position_xy, position_z;
222 
223  foot_state.rpy_.setZero();
224  foot_state.rpy_[humoto::AngleIndex::YAW] = walk_state.theta_;
225  }
226 
227 
228 
229  public:
231 
232 
235 
236  Eigen::MatrixXd Ir_;
237  Eigen::MatrixXd V_;
238  Eigen::MatrixXd V0_;
239  Eigen::MatrixXd Vfp_;
240  Eigen::MatrixXd vfp_;
241 
242  Eigen::MatrixXd S_;
243  Eigen::MatrixXd s_;
244 
246 
247  Eigen::MatrixXd Sdz_;
248  Eigen::MatrixXd sdz_;
249 
250 
251  Eigen::VectorXd cop_profile;
252  Eigen::VectorXd dcop_profile;
253  Eigen::VectorXd cstate_profile;
254  Eigen::VectorXd footpos_profile;
255 
256 
257  public:
258  /**
259  * @brief Constructor
260  */
261  MPCforWPG() : velocity_selector_(3,1)
262  {
263  solution_is_parsed_ = false;
264  }
265 
266 
267  /**
268  * @brief Constructor
269  *
270  * @param[in] mpc_parameters parameters of the MPC
271  */
272  explicit MPCforWPG(const humoto::wpg04::MPCParameters &mpc_parameters)
273  : velocity_selector_(3,1)
274  {
275  solution_is_parsed_ = false;
276  setParameters(mpc_parameters);
277  }
278 
279 
280  /**
281  * @brief Set parameters
282  *
283  * @param[in] mpc_parameters
284  */
285  void setParameters (const humoto::wpg04::MPCParameters &mpc_parameters)
286  {
287  mpc_parameters_ = mpc_parameters;
288  }
289 
290 
291  /**
292  * @brief Update control problem
293  *
294  * @param[in] model model of the system
295  * @param[in] stance_fsm walking finite state machine
296  * @param[in] walk_parameters
297  *
298  * @return ControlProblemStatus::OK/ControlProblemStatus::STOPPED
299  */
303  const humoto::wpg04::WalkParameters &walk_parameters)
304  {
306  solution_is_parsed_ = false;
307 
308  if (preview_horizon_.form( mpc_parameters_,
309  model,
310  stance_fsm,
311  walk_parameters) )
312  {
313  // decision variables
314  sol_structure_.reset();
315  sol_structure_.addSolutionPart(COP_VARIABLES_ID, mpc_parameters_.preview_horizon_length_ * 2);
316  sol_structure_.addSolutionPart(FOOTPOS_VARIABLES_ID, preview_horizon_.getNumberOfVariableSteps() * 2);
317 
318  std::size_t number_of_state_variables = model.Ns_ * mpc_parameters_.preview_horizon_length_;
319 
320 
321  // Initialize matrices
322  formRotationMatrices();
323  formFootPosMatrices(model);
324 
325 
326  // condensing
327  std::vector<etools::Matrix3> A_matrices;
328  std::vector<etools::Vector3> B_matrices;
329 
330  std::vector<etools::Matrix1x3> D_matrices;
331  std::vector<double> E_matrices;
332 
333  A_matrices.resize(mpc_parameters_.preview_horizon_length_);
334  B_matrices.resize(mpc_parameters_.preview_horizon_length_);
335  D_matrices.resize(mpc_parameters_.preview_horizon_length_);
336  E_matrices.resize(mpc_parameters_.preview_horizon_length_);
337 
338 
339  for (std::size_t i = 0; i < mpc_parameters_.preview_horizon_length_; ++i)
340  {
341  double T = preview_horizon_.intervals_[i].T_;
342  double omega = preview_horizon_.intervals_[i].omega_;
343 
344  A_matrices[i] = model.getA3(T, omega);
345  B_matrices[i] = model.getB3(T, omega);
346 
347  D_matrices[i] = model.getD3(T, omega);
348  E_matrices[i] = model.getE3(T);
349  }
350 
353 // etools::GenericBlockMatrix<3,1> Uu;
354  condense(Ux, Uu, A_matrices, B_matrices);
355 
358  condenseOutput(Ox, Ou, D_matrices, E_matrices, Ux, Uu);
359 
360 
361  etools::GenericBlockMatrix<3,1> UuIr(Uu*Ir_);
362  etools::GenericBlockMatrix<1,1> OuIr(Ou*Ir_);
363 
364  etools::GenericBlockMatrix<3,1> Uu1n(Uu.getRaw().rowwise().sum());
365  etools::GenericBlockMatrix<1,1> Ou1n(Ou.getRaw().rowwise().sum());
366 
367  // -----
368 
369  S_.resize (number_of_state_variables, sol_structure_.getNumberOfVariables ());
370  S_ << Uu.getBlockKroneckerProduct(2) * Rh_,
371  UuIr.getBlockKroneckerProduct(2) * R_;
372 
373  s_.noalias() = Uu1n.getBlockKroneckerProduct(2) * model.current_support_position_
374  + Ux.getBlockKroneckerProduct(2) * model.getCState();
375 
376  // -----
377 
378  Sdz_.resize (2*mpc_parameters_.preview_horizon_length_, sol_structure_.getNumberOfVariables ());
379  Sdz_ << Ou.getBlockKroneckerProduct(2) * Rh_,
380  OuIr.getBlockKroneckerProduct(2) * R_;
381  sdz_.noalias() = Ou1n.getBlockKroneckerProduct(2) * model.current_support_position_
382  + Ox.getBlockKroneckerProduct(2) * model.getCState();
383 
384  control_status = ControlProblemStatus::OK;
385  }
386  else
387  {
388  control_status = ControlProblemStatus::STOPPED;
389  }
390 
391  return (control_status);
392  }
393 
394 
395  /**
396  * @brief Process solution
397  *
398  * @param[in] solution solution
399  */
400  void parseSolution(const humoto::Solution &solution)
401  {
402  Eigen::VectorXd mpc_variables;
403  Eigen::VectorXd cop_local;
404  Eigen::VectorXd footpos_local;
405 
406  cop_local = solution.getSolutionPart(COP_VARIABLES_ID);
407  footpos_local = solution.getSolutionPart(FOOTPOS_VARIABLES_ID);
408 
409  mpc_variables.resize(cop_local.rows() + footpos_local.rows());
410  mpc_variables << cop_local, footpos_local;
411 
412  cop_profile.noalias() = Rh_ * cop_local + V_ * footpos_local + V0_;
413  dcop_profile.noalias() = Sdz_ * mpc_variables + sdz_;
414  cstate_profile.noalias() = S_ * mpc_variables + s_;
415 
416  footpos_profile.noalias() = Vfp_ * footpos_local + vfp_;
417 
418  solution_is_parsed_ = true;
419  }
420 
421 
422  /**
423  * @brief Get next model state.
424  *
425  * @param[in] solution solution
426  * @param[in] stance_fsm walking finite state machine (must be updated before)
427  * @param[in] model model
428  *
429  * @return next model state.
430  */
432  const humoto::Solution &solution,
434  const humoto::wpg04::Model &model)
435  {
436  HUMOTO_ASSERT(solution_is_parsed_ == false, "The solution is parsed.");
437  parseSolution(solution);
438  return(initializeNextModelState(stance_fsm, model));
439  }
440 
441 
442  /**
443  * @brief Get next model state.
444  *
445  * @param[in] stance_fsm walking finite state machine (must be updated before)
446  * @param[in] model model
447  *
448  * @return next model state.
449  */
452  const humoto::wpg04::Model &model) const
453  {
454  HUMOTO_ASSERT(solution_is_parsed_ == true, "This function can be called only after the solution is parsed.");
455  return(initializeNextModelState(stance_fsm, model));
456  }
457 
458 
459 
460  /**
461  * @brief Get landing state of a foot.
462  *
463  * @param[in] model model
464  *
465  * @return state of the foot
466  */
468  {
469  HUMOTO_ASSERT(solution_is_parsed_ == true, "This function can be called only after the solution is parsed.");
472  "This function can be executed in a single support only.");
473 
475 
476  switch (model.state_.stance_type_)
477  {
479  getFootLandingState(state, model, humoto::LeftOrRight::RIGHT);
480  break;
481 
483  getFootLandingState(state, model, humoto::LeftOrRight::LEFT);
484  break;
485 
486  default:
487  HUMOTO_THROW_MSG("Unknown state type.");
488  break;
489  }
490 
491  return(state);
492  }
493 
494 
495 
496  /**
497  * @brief Guess solution
498  *
499  * @param[out] solution_guess solution guess
500  * @param[in] old_solution old solution
501  */
502  void guessSolution( Solution &solution_guess,
503  const Solution &old_solution) const
504  {
505  solution_guess.initialize(sol_structure_, 0.0);
506 
507 
508  if ( (old_solution.isNonEmpty()) && (old_solution.getNumberOfVariables() != 0) )
509  {
510  Location old_part = old_solution.getSolutionPartLocation(COP_VARIABLES_ID);
511  Location guess_part = solution_guess.getSolutionPartLocation(COP_VARIABLES_ID);
512 
513  guess_part.length_ -= 2;
514 
515  old_part.offset_ +=2;
516  old_part.length_ -=2;
517 
518  solution_guess.getData(guess_part) = old_solution.getData(old_part);
519 
520 
521 
522  old_part = old_solution.getSolutionPartLocation(FOOTPOS_VARIABLES_ID);
523  guess_part = solution_guess.getSolutionPartLocation(FOOTPOS_VARIABLES_ID);
524 
525  if (old_part.length_ == guess_part.length_)
526  {
527  solution_guess.getData(guess_part) = old_solution.getData(old_part);
528  }
529  else
530  {
531  if (old_part.length_ > guess_part.length_)
532  {
533  old_part.offset_ +=2;
534  old_part.length_ -=2;
535  solution_guess.getData(guess_part) = old_solution.getData(old_part);
536  }
537  else
538  {
539  guess_part.length_ -= 2;
540  solution_guess.getData(guess_part) = old_solution.getData(old_part);
541  }
542  }
543  }
544  }
545 
546 
547  /**
548  * @brief Computes CoM state at the given time instant
549  *
550  * @param[in] model model
551  * @param[in] time_instant_ms time instant
552  *
553  * @return CoM state.
554  */
556  const std::size_t time_instant_ms)
557  {
558  HUMOTO_ASSERT(solution_is_parsed_ == true, "This function can be called only after the solution is parsed.");
559  std::size_t interval_index;
560  std::size_t time_offset_ms = time_instant_ms;
561  std::size_t interval_duration_ms;
562  double com_height;
563 
564  for (interval_index = 0; interval_index < preview_horizon_.intervals_.size(); ++interval_index)
565  {
566  interval_duration_ms = preview_horizon_.intervals_[interval_index].T_ms_;
567  if (time_offset_ms > interval_duration_ms)
568  {
569  time_offset_ms -= interval_duration_ms;
570  }
571  else
572  {
573  com_height = preview_horizon_.intervals_[interval_index].com_height_;
574  break;
575  }
576  }
577 
578  HUMOTO_ASSERT((interval_index < preview_horizon_.intervals_.size()),
579  "Given time instant is not included in the preview horizon.");
580 
581 
582  etools::Vector6 preceding_cstate;
583  etools::Vector2 control;
584 
585 
586  if (interval_index == 0)
587  {
588  preceding_cstate = model.getCState();
589  }
590  else
591  {
592  preceding_cstate = cstate_profile.segment((interval_index - 1)*model.Ns_, model.Ns_);
593  }
594  control = cop_profile.segment(interval_index*2, 2);
595 
597 
598  com_state = model.evaluate(convertMillisecondToSecond(time_offset_ms),
599  convertMillisecondToSecond(interval_duration_ms),
600  com_height,
601  preceding_cstate,
602  control);
603 
604  return (com_state);
605  }
606 
607 
608  /**
609  * @brief Returns length of the preview horizon
610  *
611  * @return length of preview horizon
612  */
613  std::size_t getPreviewHorizonLength() const
614  {
615  return (mpc_parameters_.preview_horizon_length_);
616  }
617 
618 
619  /**
620  * @brief Log
621  *
622  * @param[in,out] logger logger
623  * @param[in] parent parent
624  * @param[in] name name
625  */
627  const LogEntryName &parent = LogEntryName(),
628  const std::string &name = "mpcwpg") const
629  {
630  LogEntryName subname = parent; subname.add(name);
631 
632  preview_horizon_.log(logger, subname);
633 
634 
635  logger.log(LogEntryName(subname).add("R") , R_.getRaw());
636  logger.log(LogEntryName(subname).add("Rh"), Rh_.getRaw());
637 
638 
639  logger.log(LogEntryName(subname).add("V") , V_);
640  logger.log(LogEntryName(subname).add("V0") , V0_);
641  logger.log(LogEntryName(subname).add("Vfp"), Vfp_);
642  logger.log(LogEntryName(subname).add("vfp"), vfp_);
643 
644 
645  logger.log(LogEntryName(subname).add("S") , S_);
646  logger.log(LogEntryName(subname).add("s") , s_);
647  logger.log(LogEntryName(subname).add("Sdz"), Sdz_);
648  logger.log(LogEntryName(subname).add("sdz"), sdz_);
649 
650 
651  logger.log(LogEntryName(subname).add("cop_profile") , cop_profile);
652  logger.log(LogEntryName(subname).add("dcop_profile") , dcop_profile);
653  logger.log(LogEntryName(subname).add("cstate_profile") , cstate_profile);
654  logger.log(LogEntryName(subname).add("footpos_profile"), footpos_profile);
655  }
656  };
657  }
658 }
659 
void setParameters(const humoto::wpg04::MPCParameters &mpc_parameters)
Set parameters.
Definition: mpc_wpg.h:285
humoto::rigidbody::RigidBodyState getFootState(const humoto::LeftOrRight::Type left_or_right) const
Returns current foot state.
Definition: model.h:119
static double getE3(const double T)
Create E matrix of final model.
BlockKroneckerProductBase< const DecayedRawMatrix &, t_block_rows_num, t_block_cols_num, t_sparsity_type > getBlockKroneckerProduct(const std::ptrdiff_t identity_size) const
Get block Kronecker product of this matrix.
Definition: blockmatrix.h:223
std::size_t getNumberOfVariables() const
Get total number of variables in the solution vector.
Definition: solution.h:109
etools::DiagonalBlockMatrix< 2, 2 > Rh_
Definition: mpc_wpg.h:234
humoto::rigidbody::PointMassState com_state_
State of the CoM.
Definition: model_state.h:84
A shorthand class for a specific sparsity type.
Definition: blockmatrix.h:270
static const char * COP_VARIABLES_ID
Definition: common.h:17
Class that groups together parameters related to a robot foot.
std::size_t preview_horizon_length_
Length of the preview horizon (N)
Definition: common.h:144
#define HUMOTO_LOCAL
Definition: export_import.h:26
Preview horizon of an MPC [form_preview_horizon.m].
etools::Vector2 current_support_position_
2d position of the current support (center of a foot or ADS)
Definition: model.h:77
const int Nu_
Number of control variables.
Eigen::VectorXd footpos_profile
Definition: mpc_wpg.h:254
Eigen::MatrixXd Vfp_
Definition: mpc_wpg.h:239
Eigen::VectorBlock< Eigen::VectorXd > getSolutionPart(const std::string &id)
Get part of the solution by its id.
Definition: solution.h:281
const std::size_t Ns_
Number of state variables.
double getSubsamplingTime() const
getSubsamplingTime
Definition: common.h:199
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Definition: logger.h:997
#define HUMOTO_ASSERT(condition, message)
Eigen::VectorBlock< Eigen::VectorXd > getData(const Location &location)
Get data from solution vector.
Definition: solution.h:294
etools::Vector2 getFootPositionFromADS(const humoto::LeftOrRight::Type left_or_right, const etools::Matrix2 &ref_R, const etools::Vector2 &ref_position) const
Get position of a foot or aligned double support based on position of an aligned support or a foot...
A shorthand class for a specific sparsity type.
Definition: blockmatrix.h:86
Parameters of an MPC problem. [set_parameters_mpc.m].
Definition: common.h:80
double HUMOTO_LOCAL convertMillisecondToSecond(const std::size_t milliseconds)
Converts milliseconds to seconds.
Definition: time.h:22
walking::StanceType::Type next_stance_type_
next stance type
Definition: model_state.h:93
Container of the solution.
Definition: solution.h:176
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
Definition: logger.h:169
void setRight(const t_Data &data)
Get/set/copy left or right object.
Definition: leftright.h:108
Eigen::MatrixXd Ir_
Definition: mpc_wpg.h:236
bool isNonEmpty() const
Checks if the structure is empty or not.
Definition: solution.h:88
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
Definition: utility.h:26
humoto::wpg04::ModelState getNextModelState(const humoto::Solution &solution, const humoto::walking::StanceFiniteStateMachine &stance_fsm, const humoto::wpg04::Model &model)
Get next model state.
Definition: mpc_wpg.h:431
std::size_t length_
Definition: utility.h:150
[initialize_model.m]
Definition: model.h:25
A shorthand class for a specific sparsity type.
Definition: blockmatrix.h:266
void resize(const std::ptrdiff_t num_blocks_vert, const std::ptrdiff_t num_blocks_hor)
Resize matrix.
std::size_t getNumberOfVariableSteps() const
Returns number of variable steps in the preview.
Class containing options of the walking pattern generator.
Definition: common.h:24
Eigen::MatrixXd Sdz_
Definition: mpc_wpg.h:247
static humoto::rigidbody::PointMassState evaluate(const double Ts, const double T, const double com_height, const etools::Vector6 &cstate, const etools::Vector2 &control)
void guessSolution(Solution &solution_guess, const Solution &old_solution) const
Guess solution.
Definition: mpc_wpg.h:502
humoto::LeftRightContainer< humoto::rigidbody::RigidBodyState > feet_
States of the feet.
Definition: model_state.h:87
humoto::wpg04::ModelState getNextModelState(const humoto::walking::StanceFiniteStateMachine &stance_fsm, const humoto::wpg04::Model &model) const
Get next model state.
Definition: mpc_wpg.h:450
void parseSolution(const humoto::Solution &solution)
Process solution.
Definition: mpc_wpg.h:400
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
void unset()
Initialize state (everything is set to NaN).
void initialize(const SolutionStructure &sol_structure)
Initialize the solution vector.
Definition: solution.h:214
bool form(const MPCParameters &mpc_params, const Model &model, const humoto::walking::StanceFiniteStateMachine &stance_fsm, const WalkParameters &walk_parameters)
Form the preview horizon object.
static etools::Matrix1x3 getD3(const double T, const double omega)
Create D matrix of final model.
std::vector< PreviewHorizonInterval > intervals_
Eigen::VectorXd cstate_profile
Definition: mpc_wpg.h:253
static const char * FOOTPOS_VARIABLES_ID
Definition: common.h:18
void setLeft(const t_Data &data)
Get/set/copy left or right object.
Definition: leftright.h:105
etools::Vector6 getCState() const
Get cstate.
Definition: model.h:129
Location getSolutionPartLocation(const std::string &id) const
Get location of a data in the solution vector.
Definition: solution.h:122
Model Predictive Control problem for walking pattern generation [determine_solution_structure.m, form_rotation_matrices.m, form_foot_pos_matrices.m, form_condensing_matrices.m].
Definition: mpc_wpg.h:21
Selection matrix.
Definition: eigentools.h:778
etools::DiagonalBlockMatrix< 2, 2 > R_
Definition: mpc_wpg.h:233
etools::Matrix2 rotation_
The root namespace of HuMoTo.
Definition: config.h:12
Eigen::MatrixXd V0_
Definition: mpc_wpg.h:238
walking::StanceType::Type stance_type_
current stance type
Definition: model_state.h:90
void log(humoto::Logger &, const LogEntryName &, const std::string &) const
Log.
Class that groups together parmeters related to a robot foot.
etools::SelectionMatrix velocity_selector_
Definition: mpc_wpg.h:245
t_Data & getRight()
Get/set/copy left or right object.
Definition: leftright.h:99
Eigen::VectorXd dcop_profile
Definition: mpc_wpg.h:252
Eigen::MatrixXd V_
Definition: mpc_wpg.h:237
void formFootPosMatrices(const humoto::wpg04::Model &model)
Create the foot position matrices.
Definition: mpc_wpg.h:61
std::size_t getPreviewHorizonLength() const
Returns length of the preview horizon.
Definition: mpc_wpg.h:613
Stance getNextStance() const
Preview next walk state of the FSM.
MPCforWPG(const humoto::wpg04::MPCParameters &mpc_parameters)
Constructor.
Definition: mpc_wpg.h:272
humoto::rigidbody::RigidBodyState getFootLandingState(const humoto::wpg04::Model &model) const
Get landing state of a foot.
Definition: mpc_wpg.h:467
A class representing a "state" of the walk.
humoto::wpg04::ModelState state_
state of the model
Definition: model.h:75
ControlProblemStatus::Status update(const humoto::wpg04::Model &model, const humoto::walking::StanceFiniteStateMachine &stance_fsm, const humoto::wpg04::WalkParameters &walk_parameters)
Update control problem.
Definition: mpc_wpg.h:301
static etools::Vector3 getB3(const double T, const double omega, const double Tsample)
Create B matrix of final model.
void getFootLandingState(humoto::rigidbody::RigidBodyState &foot_state, const humoto::wpg04::Model &model, const humoto::LeftOrRight::Type landing_foot) const
Determine landing state of a foot.
Definition: mpc_wpg.h:181
humoto::rigidbody::PointMassState getCoMState(const humoto::wpg04::Model &model, const std::size_t time_instant_ms)
Computes CoM state at the given time instant.
Definition: mpc_wpg.h:555
static etools::Matrix3 getA3(const double T, const double omega, const double Tsample)
Create A matrix of final model.
Finite state machine for walking. [initialize_contact_walk_fsm.m].
humoto::wpg04::ModelState initializeNextModelState(const humoto::walking::StanceFiniteStateMachine &stance_fsm, const humoto::wpg04::Model &model) const
Initialize next model state.
Definition: mpc_wpg.h:95
void formRotationMatrices()
Create the rotation matrices of the MPC problem.
Definition: mpc_wpg.h:32
LogEntryName & add(const char *name)
extends entry name with a subname
Definition: logger.h:232
t_Data & getLeft()
Get/set/copy left or right object.
Definition: leftright.h:93
Eigen::MatrixXd vfp_
Definition: mpc_wpg.h:240
Location of a data chunk (offset + length).
Definition: utility.h:146
Eigen::VectorXd cop_profile
Definition: mpc_wpg.h:251
Eigen::MatrixXd sdz_
Definition: mpc_wpg.h:248
humoto::wpg04::MPCParameters mpc_parameters_
Definition: mpc_wpg.h:25
MPCforWPG()
Constructor.
Definition: mpc_wpg.h:261
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="mpcwpg") const
Log.
Definition: mpc_wpg.h:626
Abstract base class for Model Predictive Control problems.
std::size_t offset_
Definition: utility.h:149
void setDefaults()
Initialize state (everything is set to zeros).
static Type invert(const Type left_or_right)
Exchange left and right.
Definition: leftright.h:37
Eigen::MatrixXd s_
Definition: mpc_wpg.h:243
humoto::wpg04::PreviewHorizon preview_horizon_
Definition: mpc_wpg.h:230
Eigen::MatrixXd S_
Definition: mpc_wpg.h:242