centroidal_control_collection
StepMpc.h
Go to the documentation of this file.
1 /* Author: Masaki Murooka */
2 
3 #pragma once
4 
5 #include <optional>
6 
8 
9 namespace CCC
10 {
17 class StepMpc1d
18 {
19  friend class StepMpc;
20 
21 public:
24 
26  class StepModel : public _StateSpaceModel
27  {
28  public:
33  StepModel(double com_height, double step_duration);
34  };
35 
37  struct RefData
38  {
40  struct Element
41  {
43  bool is_single_support = true;
44 
46  double zmp = 0;
47 
49  double end_time = 0;
50  };
51 
57  std::vector<Element> element_list;
58  };
59 
61  struct PlannedData
62  {
64  double current_zmp = 0;
65 
70  std::optional<double> next_foot_zmp;
71  };
72 
77  using InitialParam = Eigen::Vector2d;
78 
80  struct WeightParam
81  {
83  double free_zmp;
84 
86  double fixed_zmp;
87 
90 
92  double pos;
93 
95  double vel;
96 
99 
102 
112  WeightParam(double _free_zmp = 1e-2,
113  double _fixed_zmp = 1e0,
114  double _double_support = 1e0,
115  double _pos = 0.0,
116  double _vel = 0.0,
117  double _capture_point_abs = 1e1,
118  double _capture_point_rel = 1e1)
119  : free_zmp(_free_zmp), fixed_zmp(_fixed_zmp), double_support(_double_support), pos(_pos), vel(_vel),
120  capture_point_abs(_capture_point_abs), capture_point_rel(_capture_point_rel)
121  {
122  }
123  };
124 
125 public:
130  StepMpc1d(double com_height, const WeightParam & weight_param = WeightParam())
131  : com_height_(com_height), weight_param_(weight_param)
132  {
133  }
134 
141  PlannedData planOnce(const RefData & ref_data, const InitialParam & initial_param, double current_time);
142 
143 protected:
145  double com_height_ = 0;
146 
149 
151  std::shared_ptr<VariantSequentialExtension<2>> seq_ext_;
152 };
153 
163 class StepMpc
164 {
165 public:
167  struct RefData
168  {
170  struct Element
171  {
172  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
173 
175  bool is_single_support = true;
176 
178  Eigen::Vector2d zmp = Eigen::Vector2d::Zero();
179 
181  double end_time = 0;
182  };
183 
189  std::vector<Element> element_list;
190  };
191 
193  struct PlannedData
194  {
195  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
196 
198  Eigen::Vector2d current_zmp = Eigen::Vector2d::Zero();
199 
204  std::optional<Eigen::Vector2d> next_foot_zmp;
205  };
206 
209  {
210  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
211 
213  Eigen::Vector2d pos = Eigen::Vector2d::Zero();
214 
216  Eigen::Vector2d vel = Eigen::Vector2d::Zero();
217  };
218 
219 public:
224  StepMpc(double com_height, const StepMpc1d::WeightParam & weight_param = StepMpc1d::WeightParam())
225  : mpc_1d_(std::make_shared<StepMpc1d>(com_height, weight_param))
226  {
227  }
228 
235  PlannedData planOnce(const RefData & ref_data, const InitialParam & initial_param, double current_time);
236 
237 protected:
239  std::shared_ptr<StepMpc1d> mpc_1d_;
240 };
241 } // namespace CCC
CCC::StepMpc::RefData::element_list
std::vector< Element > element_list
List of reference element.
Definition: StepMpc.h:189
VariantSequentialExtension.h
CCC::StepMpc::RefData::Element::end_time
double end_time
End time [sec].
Definition: StepMpc.h:181
CCC::StepMpc1d::RefData::Element
Element of reference data.
Definition: StepMpc.h:40
CCC::StepMpc1d::WeightParam::fixed_zmp
double fixed_zmp
Weight of fixed ZMP (for existing contacts)
Definition: StepMpc.h:86
CCC::StepMpc1d::PlannedData::next_foot_zmp
std::optional< double > next_foot_zmp
ZMP of next foot [m].
Definition: StepMpc.h:70
CCC::StepMpc1d::WeightParam::capture_point_rel
double capture_point_rel
Weight of relative position of capture point and ZMP.
Definition: StepMpc.h:101
CCC::StepMpc::RefData::Element::zmp
Eigen::Vector2d zmp
ZMP [m].
Definition: StepMpc.h:178
CCC::StepMpc::InitialParam::pos
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector2d pos
CoM position [m].
Definition: StepMpc.h:213
CCC::StepMpc1d::StepModel::StepModel
StepModel(double com_height, double step_duration)
Constructor.
CCC::StepMpc::RefData::Element
Element of reference data.
Definition: StepMpc.h:170
CCC::StepMpc::RefData::Element::is_single_support
EIGEN_MAKE_ALIGNED_OPERATOR_NEW bool is_single_support
Whether it is in single support phase.
Definition: StepMpc.h:175
CCC::StepMpc::RefData
Reference data.
Definition: StepMpc.h:167
CCC::StepMpc1d::WeightParam::pos
double pos
Weight of CoM position.
Definition: StepMpc.h:92
CCC::StepMpc::planOnce
PlannedData planOnce(const RefData &ref_data, const InitialParam &initial_param, double current_time)
Plan one step.
CCC::StepMpc1d::RefData::Element::zmp
double zmp
ZMP [m].
Definition: StepMpc.h:46
CCC::StepMpc1d::WeightParam::free_zmp
double free_zmp
Weight of free ZMP (for future contacts)
Definition: StepMpc.h:83
CCC::StepMpc::InitialParam
Initial parameter.
Definition: StepMpc.h:208
CCC::StepMpc1d::WeightParam::vel
double vel
Weight of CoM velocity.
Definition: StepMpc.h:95
CCC::StepMpc::PlannedData::next_foot_zmp
std::optional< Eigen::Vector2d > next_foot_zmp
ZMP of next foot [m].
Definition: StepMpc.h:204
CCC::StepMpc1d::StepModel
Discrete dynamics on step switching.
Definition: StepMpc.h:26
CCC::StepMpc
Linear MPC based on discrete dynamics on step switching.
Definition: StepMpc.h:163
CCC::StepMpc1d::InitialParam
Eigen::Vector2d InitialParam
Initial parameter.
Definition: StepMpc.h:77
CCC::StepMpc1d::RefData
Reference data.
Definition: StepMpc.h:37
CCC::StepMpc1d::com_height_
double com_height_
Height of robot CoM [m].
Definition: StepMpc.h:145
CCC::StepMpc1d::RefData::Element::end_time
double end_time
End time [sec].
Definition: StepMpc.h:49
CCC::StepMpc1d::PlannedData::current_zmp
double current_zmp
Current ZMP [m].
Definition: StepMpc.h:64
CCC::StepMpc1d::WeightParam::double_support
double double_support
Weight of ZMP in double support phase.
Definition: StepMpc.h:89
CCC::StateSpaceModel
State-space model.
Definition: StateSpaceModel.h:21
CCC
Definition: CommonModels.h:7
CCC::StepMpc1d::PlannedData
Planned data.
Definition: StepMpc.h:61
CCC::StepMpc::PlannedData::current_zmp
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector2d current_zmp
Current ZMP [m].
Definition: StepMpc.h:198
CCC::StepMpc1d
Linear MPC based on one-dimensional discrete dynamics on step switching.
Definition: StepMpc.h:17
CCC::StepMpc1d::RefData::Element::is_single_support
bool is_single_support
Whether it is in single support phase.
Definition: StepMpc.h:43
CCC::StepMpc1d::RefData::element_list
std::vector< Element > element_list
List of reference element.
Definition: StepMpc.h:57
CCC::StepMpc1d::WeightParam::WeightParam
WeightParam(double _free_zmp=1e-2, double _fixed_zmp=1e0, double _double_support=1e0, double _pos=0.0, double _vel=0.0, double _capture_point_abs=1e1, double _capture_point_rel=1e1)
Constructor.
Definition: StepMpc.h:112
CCC::StepMpc1d::planOnce
PlannedData planOnce(const RefData &ref_data, const InitialParam &initial_param, double current_time)
Plan one step.
CCC::StepMpc::mpc_1d_
std::shared_ptr< StepMpc1d > mpc_1d_
One-dimensional linear MPC.
Definition: StepMpc.h:239
CCC::StepMpc1d::seq_ext_
std::shared_ptr< VariantSequentialExtension< 2 > > seq_ext_
Sequential extension of state-space model.
Definition: StepMpc.h:151
CCC::StepMpc1d::WeightParam
Weight parameter.
Definition: StepMpc.h:80
CCC::StepMpc::InitialParam::vel
Eigen::Vector2d vel
CoM velocity [m/s].
Definition: StepMpc.h:216
CCC::StepMpc::StepMpc
StepMpc(double com_height, const StepMpc1d::WeightParam &weight_param=StepMpc1d::WeightParam())
Constructor.
Definition: StepMpc.h:224
CCC::StepMpc::PlannedData
Planned data.
Definition: StepMpc.h:193
CCC::StepMpc1d::StepMpc1d
StepMpc1d(double com_height, const WeightParam &weight_param=WeightParam())
Constructor.
Definition: StepMpc.h:130
CCC::StepMpc1d::WeightParam::capture_point_abs
double capture_point_abs
Weight of absolute position of capture point.
Definition: StepMpc.h:98
CCC::StepMpc1d::weight_param_
WeightParam weight_param_
Weight parameter.
Definition: StepMpc.h:148