humoto
task_basevelocitybounds.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 base velocity to a square
19  */
21  {
22  public:
23  TaskBaseVelocityBounds() : TaskILU("TaskBaseVelocityBounds")
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 
36 
37  humoto::IndexVector &I = getIndices();
38  Eigen::VectorXd &lb = getLowerBounds();
39  Eigen::VectorXd &ub = getUpperBounds();
40 
41  I.resize (loc_var.length_);
42  lb.resize(loc_var.length_);
43  ub.resize(loc_var.length_);
44 
45  for (std::size_t i = 0; i < loc_var.length_/2; ++i)
46  {
47  I[i*2] = loc_var.offset_ + i*2;
48  I[i*2+1] = loc_var.offset_ + i*2 + 1;
49 
50  lb.segment(i*2, 2) = mpc.preview_horizon_.getNominalBaseVelocityBounds(i).col(0);
51  ub.segment(i*2, 2) = mpc.preview_horizon_.getNominalBaseVelocityBounds(i).col(1);
52  }
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 base velocity variables 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)
#define HUMOTO_LOCAL
Definition: export_import.h:26
static const char * BASE_VEL_VARIABLES_ID
Definition: common.h:17
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::Matrix< unsigned int, Eigen::Dynamic, 1 > IndexVector
Definition: utility.h:19
void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
Task for bounding base velocity to a square.
Task: lb <= x[I] <= ub.
Definition: task.h:572
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
Location getSolutionPartLocation(const std::string &id) const
Get location of a data in the solution vector.
Definition: solution.h:122
humoto::pepper_mpc::MPCParameters mpc_parameters_
Definition: mpc_mg.h:373
etools::Matrix2 getNominalBaseVelocityBounds(const std::size_t interval_index) const
Get nominal base velocity bounds for a given interval.
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.
Location of a data chunk (offset + length).
Definition: utility.h:146
humoto::pepper_mpc::PreviewHorizon preview_horizon_
Definition: mpc_mg.h:334