centroidal_control_collection
SingularPreviewControlZmp.h
Go to the documentation of this file.
1 /* Author: Masaki Murooka */
2 
3 #pragma once
4 
5 #include <functional>
6 #include <memory>
7 
8 #include <Eigen/Dense>
9 
10 #include <CCC/Constants.h>
11 
12 namespace CCC
13 {
20 {
22 
23 public:
25  struct InitialParam
26  {
28  double pos = 0;
29 
31  double vel = 0;
32 
34  double planned_zmp = 0;
35  };
36 
37 public:
43  SingularPreviewControlZmp1d(double com_height, double horizon_duration, double horizon_dt)
44  : horizon_dt_(horizon_dt), horizon_steps_(static_cast<int>(std::ceil(horizon_duration / horizon_dt))),
45  omega_(std::sqrt(constants::g / com_height))
46  {
47  }
48 
56  double planOnce(const std::function<double(double)> & ref_zmp_func,
57  const InitialParam & initial_param,
58  double current_time,
59  double control_dt = -1) const;
60 
61 protected:
63  double procOnce(const Eigen::VectorXd & ref_zmp_seq,
64  const InitialParam & initial_param,
65  double current_time,
66  double control_dt) const;
67 
68 protected:
70  double horizon_dt_ = 0;
71 
73  int horizon_steps_ = -1;
74 
76  double omega_ = 0;
77 };
78 
87 {
88 public:
90  struct InitialParam
91  {
92  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
93 
95  Eigen::Vector2d pos = Eigen::Vector2d::Zero();
96 
98  Eigen::Vector2d vel = Eigen::Vector2d::Zero();
99 
101  Eigen::Vector2d planned_zmp = Eigen::Vector2d::Zero();
102  };
103 
104 public:
110  SingularPreviewControlZmp(double com_height, double horizon_duration, double horizon_dt)
111  : spc_1d_(std::make_shared<SingularPreviewControlZmp1d>(com_height, horizon_duration, horizon_dt))
112  {
113  }
114 
122  Eigen::Vector2d planOnce(const std::function<Eigen::Vector2d(double)> & ref_zmp_func,
123  const InitialParam & initial_param,
124  double current_time,
125  double control_dt = -1) const;
126 
127 public:
129  std::shared_ptr<SingularPreviewControlZmp1d> spc_1d_;
130 };
131 } // namespace CCC
CCC::SingularPreviewControlZmp1d::procOnce
double procOnce(const Eigen::VectorXd &ref_zmp_seq, const InitialParam &initial_param, double current_time, double control_dt) const
Process one step.
CCC::constants::g
constexpr double g
Gravitational acceleration [m/s^2].
Definition: Constants.h:10
CCC::SingularPreviewControlZmp::InitialParam::planned_zmp
Eigen::Vector2d planned_zmp
Current ZMP planned in previous step [m].
Definition: SingularPreviewControlZmp.h:101
CCC::SingularPreviewControlZmp
Singular preview control for CoM-ZMP model.
Definition: SingularPreviewControlZmp.h:86
CCC::SingularPreviewControlZmp1d
Singular preview control for one-dimensional CoM-ZMP model.
Definition: SingularPreviewControlZmp.h:19
Constants.h
CCC::SingularPreviewControlZmp1d::InitialParam::planned_zmp
double planned_zmp
Current ZMP planned in previous step [m].
Definition: SingularPreviewControlZmp.h:34
CCC::SingularPreviewControlZmp1d::InitialParam::pos
double pos
CoM position [m].
Definition: SingularPreviewControlZmp.h:28
CCC::SingularPreviewControlZmp1d::SingularPreviewControlZmp1d
SingularPreviewControlZmp1d(double com_height, double horizon_duration, double horizon_dt)
Constructor.
Definition: SingularPreviewControlZmp.h:43
CCC::SingularPreviewControlZmp::InitialParam::pos
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector2d pos
CoM position [m].
Definition: SingularPreviewControlZmp.h:95
CCC::SingularPreviewControlZmp1d::omega_
double omega_
Time constant for inverted pendulum dynamics.
Definition: SingularPreviewControlZmp.h:76
CCC
Definition: CommonModels.h:7
CCC::SingularPreviewControlZmp1d::InitialParam::vel
double vel
CoM velocity [m/s].
Definition: SingularPreviewControlZmp.h:31
CCC::SingularPreviewControlZmp::spc_1d_
std::shared_ptr< SingularPreviewControlZmp1d > spc_1d_
One-dimensional preview control.
Definition: SingularPreviewControlZmp.h:129
CCC::SingularPreviewControlZmp::InitialParam
Initial parameter.
Definition: SingularPreviewControlZmp.h:90
CCC::SingularPreviewControlZmp1d::InitialParam
Initial parameter.
Definition: SingularPreviewControlZmp.h:25
CCC::SingularPreviewControlZmp1d::horizon_dt_
double horizon_dt_
Discretization timestep in horizon [sec].
Definition: SingularPreviewControlZmp.h:70
CCC::SingularPreviewControlZmp1d::horizon_steps_
int horizon_steps_
Number of steps in horizon.
Definition: SingularPreviewControlZmp.h:73
CCC::SingularPreviewControlZmp::planOnce
Eigen::Vector2d planOnce(const std::function< Eigen::Vector2d(double)> &ref_zmp_func, const InitialParam &initial_param, double current_time, double control_dt=-1) const
Plan one step.
CCC::SingularPreviewControlZmp::InitialParam::vel
Eigen::Vector2d vel
CoM velocity [m/s].
Definition: SingularPreviewControlZmp.h:98
CCC::SingularPreviewControlZmp1d::planOnce
double planOnce(const std::function< double(double)> &ref_zmp_func, const InitialParam &initial_param, double current_time, double control_dt=-1) const
Plan one step.
CCC::SingularPreviewControlZmp::SingularPreviewControlZmp
SingularPreviewControlZmp(double com_height, double horizon_duration, double horizon_dt)
Constructor.
Definition: SingularPreviewControlZmp.h:110