humoto
task_baseaccelerationbounds.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 base acceleration bounding task
19  */
21  {
22  public:
23  TaskBaseAccelerationBounds() : TaskASLU("TaskBaseAccelerationBounds", 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  setOffset(0);
40  A.noalias() = mpc.Aas_;
41 
42  const std::size_t preview_horizon_length = mpc.preview_horizon_.getPreviewHorizonLength();
43  lb.resize(preview_horizon_length * 2);
44  ub.resize(preview_horizon_length * 2);
45 
46  for (std::size_t i = 0; i < preview_horizon_length; ++i)
47  {
48  lb.segment(i*2, 2) = mpc.preview_horizon_.getNominalBaseAccelerationBounds(i).col(0);
49  ub.segment(i*2, 2) = mpc.preview_horizon_.getNominalBaseAccelerationBounds(i).col(1);
50  }
51 
52  lb -= mpc.sas_;
53  ub -= mpc.sas_;
54  }
55 
56 
57  /// @copydoc humoto::TaskBase::guessActiveSet
58  void guessActiveSet(const humoto::SolutionStructure &sol_structure,
59  const humoto::Model &model_base,
60  const humoto::ControlProblem &control_problem)
61  {
62  const humoto::pepper_mpc::MPCforMG &mpc = dynamic_cast <const humoto::pepper_mpc::MPCforMG &> (control_problem);
63 
65  {
66  TaskBase::guessActiveSet(sol_structure, model_base, control_problem);
67  }
68  else
69  {
70  std::size_t num_ctr = mpc.preview_horizon_.getPreviewHorizonLength() * 2;
71 
72  if (getActualActiveSet().size() == 0)
73  {
74  getActiveSetGuess().initialize(num_ctr, ConstraintActivationType::INACTIVE);
75  }
76  else
77  {
78  HUMOTO_ASSERT( (getActualActiveSet().size() == num_ctr),
79  "The number of base velocity variables is not supposed to change.");
80 
81  getActiveSetGuess() = getActualActiveSet();
82 
83  getActiveSetGuess().shift(2, ConstraintActivationType::INACTIVE);
84  }
85  }
86  }
87  };
88  }//pepper
89 }//humoto
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.
#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
etools::Matrix2 getNominalBaseAccelerationBounds(const std::size_t interval_index) const
Get nominal base acceleration bounds for a given interval.
Eigen::MatrixXd Aas_
Definition: mpc_mg.h:349
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
void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
Eigen::VectorXd sas_
Definition: mpc_mg.h:348
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
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
Task: lb <= A*S*x <= ub.
Definition: task.h:548
humoto::pepper_mpc::PreviewHorizon preview_horizon_
Definition: mpc_mg.h:334