humoto
task_bodypositionbounds.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Jan Michalczyk
4  @author Alexander Sherikov
5  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #pragma once
12 
13 namespace humoto
14 {
15  namespace pepper_mpc
16  {
17  /**
18  * @brief Task for bounding body position to a square
19  */
21  {
22  public:
23  TaskBodyPositionBounds() : TaskALU("TaskBodyPositionBounds", 0.0)
24  {
25  }
26 
27 
28  /// @copydoc humoto::TaskBase::form
29  void form( const humoto::SolutionStructure &sol_structure,
30  const humoto::Model &model_base,
31  const humoto::ControlProblem &control_problem)
32  {
33  const humoto::pepper_mpc::MPCforMG &mpc = dynamic_cast <const humoto::pepper_mpc::MPCforMG &> (control_problem);
34 
35  Eigen::MatrixXd &A = getA();
36  Eigen::VectorXd &lb = getLowerBounds();
37  Eigen::VectorXd &ub = getUpperBounds();
38 
39  A.noalias() = mpc.Apd_;
40  lb.resize(A.rows());
41  ub.resize(A.rows());
42 
43  for (EigenIndex i = 0; i < lb.rows()/2; ++i)
44  {
45  lb.segment(i*2, 2) = mpc.preview_horizon_.getBodyBounds(i).col(0);
46  ub.segment(i*2, 2) = mpc.preview_horizon_.getBodyBounds(i).col(1);
47  }
48 
49  lb -= mpc.spd_;
50  ub -= mpc.spd_;
51  }
52 
53 
54  /// @copydoc humoto::TaskBase::guessActiveSet
55  void guessActiveSet(const humoto::SolutionStructure &sol_structure,
56  const humoto::Model &model_base,
57  const humoto::ControlProblem &control_problem)
58  {
59  const humoto::pepper_mpc::MPCforMG &mpc = dynamic_cast <const humoto::pepper_mpc::MPCforMG &> (control_problem);
60 
62  {
63  TaskBase::guessActiveSet(sol_structure, model_base, control_problem);
64  }
65  else
66  {
67  std::size_t num_ctr = mpc.preview_horizon_.getPreviewHorizonLength() * 2;
68 
69  if (getActualActiveSet().size() == 0)
70  {
71  getActiveSetGuess().initialize(num_ctr, ConstraintActivationType::INACTIVE);
72  }
73  else
74  {
75  HUMOTO_ASSERT( (getActualActiveSet().size() == num_ctr),
76  "The number of body position variables is not supposed to change.");
77 
78  getActiveSetGuess() = getActualActiveSet();
79 
80  getActiveSetGuess().shift(2, ConstraintActivationType::INACTIVE);
81  }
82  }
83  }
84  };
85  } //pepper
86 } //humoto
Abstract base class (for control problems)
void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
#define HUMOTO_LOCAL
Definition: export_import.h:26
std::size_t getPreviewHorizonLength() const
Get preview horizon length.
virtual void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
Definition: task.h:147
#define HUMOTO_ASSERT(condition, message)
Analog of &#39;sol_structure&#39; struct in Octave code. [determine_solution_structure.m].
Definition: solution.h:33
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
Definition: utility.h:26
etools::Matrix2 getBodyBounds(const std::size_t interval_index) const
Get body bounds.
Eigen::MatrixXd Apd_
Definition: mpc_mg.h:357
Task: lb <= A*x <= ub.
Definition: task.h:536
std::size_t sampling_time_ms_
Sampling time in milliseconds (T_ms)
Definition: common.h:316
std::size_t subsampling_time_ms_
Subsampling time in milliseconds (Ts_ms)
Definition: common.h:319
humoto::pepper_mpc::MPCParameters mpc_parameters_
Definition: mpc_mg.h:373
Eigen::VectorXd spd_
Definition: mpc_mg.h:356
Task for bounding body position to a square.
The root namespace of HuMoTo.
Definition: config.h:12
Instances of this class are passed to a virtual method &#39;humoto::TaskBase::form()&#39;, so even though this class is basically useless in its present form we cannot avoid its definition using a template.
Definition: model.h:41
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_mg.h:20
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
humoto::pepper_mpc::PreviewHorizon preview_horizon_
Definition: mpc_mg.h:334