humoto
task_terminalconstraint.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Jan Michalczyk
4  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
5  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6 
7  @brief
8 */
9 
10 #pragma once
11 
12 namespace humoto
13 {
14  namespace wpg04
15  {
16  /**
17  * @brief Terminal constraint task
18  */
20  {
21  #define HUMOTO_CONFIG_ENTRIES \
22  HUMOTO_CONFIG_PARENT_CLASS(TaskAB)
23  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
24 
25 
26  protected:
27  void setDefaults()
28  {
30  setGain(1.0);
31  }
32 
33 
34  void finalize()
35  {
37  }
38 
39 
40  public:
41  explicit TaskTerminalConstraint(const double gain = 1.0)
42  : TaskAB("TaskTerminalConstraint", gain)
43  {
44  }
45 
46 
47  /// @copydoc humoto::TaskBase::form
48  void form( const humoto::SolutionStructure &sol_structure,
49  const humoto::Model &model_base,
50  const humoto::ControlProblem &control_problem)
51  {
52  const humoto::wpg04::MPCforWPG &mpc = dynamic_cast <const humoto::wpg04::MPCforWPG &> (control_problem);
53  const humoto::wpg04::Model &model_wpg04 = dynamic_cast <const humoto::wpg04::Model &> (model_base);
54 
55  Eigen::MatrixXd &A = getA();
56  Eigen::VectorXd &b = getB();
57 
58  const std::size_t preview_length = mpc.getPreviewHorizonLength();
59  const std::size_t cstate_length = model_wpg04.getCState().size();
60 
61  etools::Matrix2x6 D = model_wpg04.getDcpv6(mpc.preview_horizon_.intervals_.back().omega_);
62 
63  A.noalias() = getGain() * D * mpc.S_.block((preview_length - 1)*cstate_length, 0, cstate_length, sol_structure.getNumberOfVariables());
64  b.noalias() = -getGain() * D * mpc.s_.block((preview_length - 1)*cstate_length, 0, cstate_length, 1);
65  };
66  };
67  }
68 }
Abstract base class (for control problems)
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x6
Definition: eigentools.h:98
std::size_t getNumberOfVariables() const
Get total number of variables in the solution vector.
Definition: solution.h:109
#define HUMOTO_LOCAL
Definition: export_import.h:26
Analog of &#39;sol_structure&#39; struct in Octave code. [determine_solution_structure.m].
Definition: solution.h:33
virtual void setDefaults()
Set members to their default values.
Definition: task.h:332
void finalize()
This function is called automaticaly after reading a configuration file. Does nothing by default...
void setDefaults()
Set members to their default values.
[initialize_model.m]
Definition: model.h:25
std::vector< PreviewHorizonInterval > intervals_
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
std::size_t getPreviewHorizonLength() const
Returns length of the preview horizon.
Definition: mpc_wpg.h:613
void finalize()
This function is called automaticaly after reading a configuration file. Does nothing by default...
Definition: task.h:337
Task: A*x = b.
Definition: task.h:542
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
Eigen::MatrixXd s_
Definition: mpc_wpg.h:243
humoto::wpg04::PreviewHorizon preview_horizon_
Definition: mpc_wpg.h:230
Eigen::MatrixXd S_
Definition: mpc_wpg.h:242