humoto
task_copbounds.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Jan Michalczyk
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 wpg04
16  {
17  /**
18  * @brief [task_copbounds.m]
19  */
21  {
22  #define HUMOTO_CONFIG_ENTRIES \
23  HUMOTO_CONFIG_PARENT_CLASS(TaskILU)
24  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
25 
26 
27  protected:
28  void setDefaults()
29  {
31  }
32 
33 
34  public:
35  TaskCoPBounds() : TaskILU("TaskCoPBounds")
36  {
37  }
38 
39 
40  /// @copydoc humoto::TaskBase::form
41  void form( const humoto::SolutionStructure &sol_structure,
42  const humoto::Model &model_base,
43  const humoto::ControlProblem &control_problem)
44  {
45  const humoto::wpg04::MPCforWPG &mpc = dynamic_cast <const humoto::wpg04::MPCforWPG &> (control_problem);
46 
47  Location loc_var = sol_structure.getSolutionPartLocation(COP_VARIABLES_ID);
48 
49  humoto::IndexVector &I = getIndices();
50  Eigen::VectorXd &lb = getLowerBounds();
51  Eigen::VectorXd &ub = getUpperBounds();
52 
53 
54  I.resize(loc_var.length_);
55  lb.resize(loc_var.length_);
56  ub.resize(loc_var.length_);
57 
58 
59  for (std::size_t i = 0; i < loc_var.length_/2; ++i)
60  {
61  I[i*2] = loc_var.offset_ + i*2;
62  I[i*2+1] = loc_var.offset_ + i*2 + 1;
63 
64  lb.segment(i*2, 2) = mpc.preview_horizon_.getCoPBounds(i).col(0);
65  ub.segment(i*2, 2) = mpc.preview_horizon_.getCoPBounds(i).col(1);
66  }
67  }
68 
69 
70  /// @copydoc humoto::TaskBase::guessActiveSet
71  void guessActiveSet(const humoto::SolutionStructure &sol_structure,
72  const humoto::Model &model_base,
73  const humoto::ControlProblem &control_problem)
74  {
75  Location loc_var = sol_structure.getSolutionPartLocation(COP_VARIABLES_ID);
76 
77 
78  if (getActualActiveSet().size() == 0)
79  {
80  getActiveSetGuess().initialize(loc_var.length_, ConstraintActivationType::INACTIVE);
81  }
82  else
83  {
84  HUMOTO_ASSERT( (getActualActiveSet().size() == loc_var.length_),
85  "The number of CoP variables is not supposed to change.");
86 
87  getActiveSetGuess() = getActualActiveSet();
88 
89  getActiveSetGuess().shift(2, ConstraintActivationType::INACTIVE);
90  }
91  }
92  };
93  }
94 }
Abstract base class (for control problems)
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
static const char * COP_VARIABLES_ID
Definition: common.h:17
#define HUMOTO_LOCAL
Definition: export_import.h:26
#define HUMOTO_ASSERT(condition, message)
void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
Analog of &#39;sol_structure&#39; struct in Octave code. [determine_solution_structure.m].
Definition: solution.h:33
etools::Matrix2 getCoPBounds(const std::size_t interval_index) const
Get CoP bounds.
std::size_t length_
Definition: utility.h:150
Eigen::Matrix< unsigned int, Eigen::Dynamic, 1 > IndexVector
Definition: utility.h:19
Task: lb <= x[I] <= ub.
Definition: task.h:572
Location getSolutionPartLocation(const std::string &id) const
Get location of a data in the solution vector.
Definition: solution.h:122
void setDefaults()
Set members to their default values.
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
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
virtual void setDefaults()
Set members to their default values.
Definition: task.h:128
Location of a data chunk (offset + length).
Definition: utility.h:146
humoto::wpg04::PreviewHorizon preview_horizon_
Definition: mpc_wpg.h:230