centroidal_control_collection
IntrinsicallyStableMpc.h
Go to the documentation of this file.
1 /* Author: Masaki Murooka */
2 
3 #pragma once
4 
5 #include <functional>
6 
7 #include <qp_solver_collection/QpSolverCollection.h>
8 
9 namespace CCC
10 {
17 {
18  friend class IntrinsicallyStableMpc;
19 
20 public:
22  struct RefData
23  {
25  double zmp = 0;
26 
28  std::array<double, 2> zmp_limits;
29  };
30 
32  struct InitialParam
33  {
35  double capture_point = 0;
36 
38  double planned_zmp = 0;
39  };
40 
42  struct WeightParam
43  {
45  double zmp;
46 
48  double zmp_vel;
49 
54  WeightParam(double _zmp = 1.0, double _zmp_vel = 1e-3) : zmp(_zmp), zmp_vel(_zmp_vel) {}
55  };
56 
57 public:
65  IntrinsicallyStableMpc1d(double com_height,
66  double horizon_duration,
67  double horizon_dt,
68  QpSolverCollection::QpSolverType qp_solver_type = QpSolverCollection::QpSolverType::Any,
69  const WeightParam & weight_param = WeightParam());
70 
78  double planOnce(const std::function<RefData(double)> & ref_data_func,
79  const InitialParam & initial_param,
80  double current_time,
81  double control_dt = -1);
82 
83 protected:
85  double procOnce(const std::vector<RefData> & ref_data_seq,
86  const InitialParam & initial_param,
87  double current_time,
88  double control_dt);
89 
90 protected:
93 
95  double horizon_dt_ = 0;
96 
98  int horizon_steps_ = -1;
99 
101  std::shared_ptr<QpSolverCollection::QpSolver> qp_solver_;
102 
104  QpSolverCollection::QpCoeff qp_coeff_;
105 
107  double omega_ = 0;
108 
110  double lambda_ = 0;
111 
113  Eigen::MatrixXd P_;
114 };
115 
122 {
123 public:
132  struct RefData
133  {
134  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
135 
137  Eigen::Vector2d zmp = Eigen::Vector2d::Zero();
138 
140  std::array<Eigen::Vector2d, 2> zmp_limits;
141  };
142 
145  {
146  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
147 
149  Eigen::Vector2d capture_point = Eigen::Vector2d::Zero();
150 
152  Eigen::Vector2d planned_zmp = Eigen::Vector2d::Zero();
153  };
154 
155 public:
164  double com_height,
165  double horizon_duration,
166  double horizon_dt,
167  QpSolverCollection::QpSolverType qp_solver_type = QpSolverCollection::QpSolverType::Any,
169  : mpc_1d_(
170  std::make_shared<IntrinsicallyStableMpc1d>(com_height, horizon_duration, horizon_dt, qp_solver_type, weight_param))
171  {
172  ref_data_seq_x_.resize(mpc_1d_->horizon_steps_);
173  ref_data_seq_y_.resize(mpc_1d_->horizon_steps_);
174  }
175 
183  Eigen::Vector2d planOnce(const std::function<RefData(double)> & ref_data_func,
184  const InitialParam & initial_param,
185  double current_time,
186  double control_dt = -1);
187 
188 protected:
190  std::shared_ptr<IntrinsicallyStableMpc1d> mpc_1d_;
191 
193  std::vector<IntrinsicallyStableMpc1d::RefData> ref_data_seq_x_;
194 
196  std::vector<IntrinsicallyStableMpc1d::RefData> ref_data_seq_y_;
197 };
198 } // namespace CCC
CCC::IntrinsicallyStableMpc1d::omega_
double omega_
Time constant for inverted pendulum dynamics.
Definition: IntrinsicallyStableMpc.h:107
CCC::IntrinsicallyStableMpc1d::WeightParam::zmp_vel
double zmp_vel
ZMP velocity weight.
Definition: IntrinsicallyStableMpc.h:48
CCC::IntrinsicallyStableMpc
QP-based MPC with stability constraint for CoM-ZMP model.
Definition: IntrinsicallyStableMpc.h:121
CCC::IntrinsicallyStableMpc1d::qp_solver_
std::shared_ptr< QpSolverCollection::QpSolver > qp_solver_
QP solver.
Definition: IntrinsicallyStableMpc.h:101
CCC::IntrinsicallyStableMpc::InitialParam::planned_zmp
Eigen::Vector2d planned_zmp
Current ZMP planned in previous step [m].
Definition: IntrinsicallyStableMpc.h:152
CCC::IntrinsicallyStableMpc::IntrinsicallyStableMpc
IntrinsicallyStableMpc(double com_height, double horizon_duration, double horizon_dt, QpSolverCollection::QpSolverType qp_solver_type=QpSolverCollection::QpSolverType::Any, const IntrinsicallyStableMpc1d::WeightParam &weight_param=IntrinsicallyStableMpc1d::WeightParam())
Constructor.
Definition: IntrinsicallyStableMpc.h:163
CCC::IntrinsicallyStableMpc1d::InitialParam::capture_point
double capture_point
Capture point [m].
Definition: IntrinsicallyStableMpc.h:35
CCC::IntrinsicallyStableMpc1d::horizon_steps_
int horizon_steps_
Number of steps in horizon.
Definition: IntrinsicallyStableMpc.h:98
CCC::IntrinsicallyStableMpc1d::qp_coeff_
QpSolverCollection::QpCoeff qp_coeff_
QP coefficients.
Definition: IntrinsicallyStableMpc.h:104
CCC::IntrinsicallyStableMpc1d
QP-based MPC with stability constraint for one-dimensional CoM-ZMP model.
Definition: IntrinsicallyStableMpc.h:16
CCC::IntrinsicallyStableMpc1d::weight_param_
WeightParam weight_param_
Weight parameter.
Definition: IntrinsicallyStableMpc.h:92
CCC::IntrinsicallyStableMpc1d::RefData::zmp
double zmp
ZMP [m].
Definition: IntrinsicallyStableMpc.h:25
CCC::IntrinsicallyStableMpc1d::RefData
Reference data.
Definition: IntrinsicallyStableMpc.h:22
CCC::IntrinsicallyStableMpc1d::InitialParam::planned_zmp
double planned_zmp
Current ZMP planned in previous step [m].
Definition: IntrinsicallyStableMpc.h:38
CCC::IntrinsicallyStableMpc1d::IntrinsicallyStableMpc1d
IntrinsicallyStableMpc1d(double com_height, double horizon_duration, double horizon_dt, QpSolverCollection::QpSolverType qp_solver_type=QpSolverCollection::QpSolverType::Any, const WeightParam &weight_param=WeightParam())
Constructor.
CCC::IntrinsicallyStableMpc1d::WeightParam::zmp
double zmp
ZMP weight.
Definition: IntrinsicallyStableMpc.h:45
CCC::IntrinsicallyStableMpc1d::procOnce
double procOnce(const std::vector< RefData > &ref_data_seq, const InitialParam &initial_param, double current_time, double control_dt)
Process one step.
CCC::IntrinsicallyStableMpc::ref_data_seq_y_
std::vector< IntrinsicallyStableMpc1d::RefData > ref_data_seq_y_
Reference data sequence of y.
Definition: IntrinsicallyStableMpc.h:196
CCC
Definition: CommonModels.h:7
CCC::IntrinsicallyStableMpc1d::horizon_dt_
double horizon_dt_
Discretization timestep in horizon [sec].
Definition: IntrinsicallyStableMpc.h:95
CCC::IntrinsicallyStableMpc::InitialParam::capture_point
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector2d capture_point
Capture point [m].
Definition: IntrinsicallyStableMpc.h:149
CCC::IntrinsicallyStableMpc::ref_data_seq_x_
std::vector< IntrinsicallyStableMpc1d::RefData > ref_data_seq_x_
Reference data sequence of x.
Definition: IntrinsicallyStableMpc.h:193
CCC::IntrinsicallyStableMpc::planOnce
Eigen::Vector2d planOnce(const std::function< RefData(double)> &ref_data_func, const InitialParam &initial_param, double current_time, double control_dt=-1)
Plan one step.
CCC::IntrinsicallyStableMpc1d::P_
Eigen::MatrixXd P_
Constant matrix dependent on horizon_dt (defined in equation (7) in the paper)
Definition: IntrinsicallyStableMpc.h:113
CCC::IntrinsicallyStableMpc::RefData::zmp
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector2d zmp
ZMP [m].
Definition: IntrinsicallyStableMpc.h:137
CCC::IntrinsicallyStableMpc1d::RefData::zmp_limits
std::array< double, 2 > zmp_limits
Min/max limits of ZMP [m].
Definition: IntrinsicallyStableMpc.h:28
CCC::IntrinsicallyStableMpc1d::lambda_
double lambda_
Constant value dependent on omega and horizon_dt.
Definition: IntrinsicallyStableMpc.h:110
CCC::IntrinsicallyStableMpc1d::planOnce
double planOnce(const std::function< RefData(double)> &ref_data_func, const InitialParam &initial_param, double current_time, double control_dt=-1)
Plan one step.
CCC::IntrinsicallyStableMpc::RefData
Reference data.
Definition: IntrinsicallyStableMpc.h:132
CCC::IntrinsicallyStableMpc1d::WeightParam
Weight parameter.
Definition: IntrinsicallyStableMpc.h:42
CCC::IntrinsicallyStableMpc::RefData::zmp_limits
std::array< Eigen::Vector2d, 2 > zmp_limits
Min/max limits of ZMP [m].
Definition: IntrinsicallyStableMpc.h:140
CCC::IntrinsicallyStableMpc1d::InitialParam
Initial parameter.
Definition: IntrinsicallyStableMpc.h:32
CCC::IntrinsicallyStableMpc1d::WeightParam::WeightParam
WeightParam(double _zmp=1.0, double _zmp_vel=1e-3)
Constructor.
Definition: IntrinsicallyStableMpc.h:54
CCC::IntrinsicallyStableMpc::mpc_1d_
std::shared_ptr< IntrinsicallyStableMpc1d > mpc_1d_
One-dimensional linear MPC.
Definition: IntrinsicallyStableMpc.h:190
CCC::IntrinsicallyStableMpc::InitialParam
Initial parameter.
Definition: IntrinsicallyStableMpc.h:144