humoto
task_coppositionbounds.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 CoP position bounding task
19  */
21  {
22  public:
23  TaskCoPPositionBounds() : TaskALU("TaskCoPPositionBounds", 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.Ap_;
40 
41  const std::size_t preview_horizon_length = mpc.preview_horizon_.getPreviewHorizonLength();
42  lb.resize(preview_horizon_length * 2);
43  ub.resize(preview_horizon_length * 2);
44 
45  for (std::size_t i = 0; i < preview_horizon_length; ++i)
46  {
47  lb.segment(i*2, 2) = mpc.preview_horizon_.getCoPBounds(i).col(0);
48  ub.segment(i*2, 2) = mpc.preview_horizon_.getCoPBounds(i).col(1);
49  }
50 
51  lb -= mpc.sp_;
52  ub -= mpc.sp_;
53  }
54 
55 
56  /// @copydoc humoto::TaskBase::guessActiveSet
57  void guessActiveSet(const humoto::SolutionStructure &sol_structure,
58  const humoto::Model &model_base,
59  const humoto::ControlProblem &control_problem)
60  {
61  const humoto::pepper_mpc::MPCforMG &mpc = dynamic_cast <const humoto::pepper_mpc::MPCforMG&>(control_problem);
62 
64  {
65  TaskBase::guessActiveSet(sol_structure, model_base, control_problem);
66  }
67  else
68  {
69  std::size_t num_ctr = mpc.preview_horizon_.getPreviewHorizonLength() * 2;
70 
71  if (getActualActiveSet().size() == 0)
72  {
73  getActiveSetGuess().initialize(num_ctr, ConstraintActivationType::INACTIVE);
74  }
75  else
76  {
77  HUMOTO_ASSERT( (getActualActiveSet().size() == num_ctr),
78  "The number of CoP constraints is not supposed to change.");
79 
80  getActiveSetGuess() = getActualActiveSet();
81 
82  getActiveSetGuess().shift(2, ConstraintActivationType::INACTIVE);
83  }
84  }
85  }
86  };
87  }//pepper
88 }//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
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
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
Eigen::MatrixXd Ap_
Definition: mpc_mg.h:345
humoto::pepper_mpc::MPCParameters mpc_parameters_
Definition: mpc_mg.h:373
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
Eigen::VectorXd sp_
Definition: mpc_mg.h:344
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
etools::Matrix2 getCoPBounds(const std::size_t interval_index) const
Get CoP bounds for given interval.
humoto::pepper_mpc::PreviewHorizon preview_horizon_
Definition: mpc_mg.h:334