30 #include <mc_planning/Pendulum.h>
31 #include <mc_rtc/constants.h>
32 #include <mc_rtc/gui.h>
33 #include <mc_rtc/log/Logger.h>
35 #include <copra/LMPC.h>
36 #include <copra/PreviewSystem.h>
37 #include <copra/constraints.h>
38 #include <copra/costFunctions.h>
55 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
73 void addGUIElements(std::shared_ptr<mc_rtc::gui::StateBuilder> gui);
85 void configure(
const mc_rtc::Configuration &);
106 void phaseDurations(
double initSupportDuration,
double doubleSupportDuration,
double targetSupportDuration);
122 double zeta = height / mc_rtc::constants::GRAVITY;
123 double omegaInv = std::sqrt(zeta);
126 1, 0, omegaInv, 0, 0, 0,
127 0, 1, 0, omegaInv, 0, 0;
129 1, 0, 0, 0, -zeta, 0,
130 0, 1, 0, 0, 0, -zeta;
158 initState_ << pendulum.com().head<2>(), pendulum.comd().head<2>(), pendulum.comdd().head<2>();
173 return indexToHrep_[i];
190 return nbInitSupportSteps_;
200 return nbDoubleSupportSteps_;
234 return targetContact_;
238 void computeZMPRef();
240 void updateTerminalConstraint();
242 void updateZMPConstraint();
244 void updateJerkCost();
246 void updateVelCost();
248 void updateZMPCost();
256 using RefVector = Eigen::Matrix<double, 2 * (
NB_STEPS + 1), 1>;
257 using StateMatrix = Eigen::Matrix<double, 2, STATE_SIZE>;
262 RefVector velRef_ = RefVector::Zero();
263 RefVector zmpRef_ = RefVector::Zero();
265 StateMatrix dcmFromState_ =
267 StateMatrix zmpFromState_ =
269 Eigen::VectorXd initState_;
271 copra::SolverFlag solver_ = copra::SolverFlag::QLD;
272 double buildAndSolveTime_ = 0.;
273 double solveTime_ = 0.;
274 std::shared_ptr<Preview> solution_ =
nullptr;
275 std::shared_ptr<copra::ControlCost> jerkCost_ =
nullptr;
276 std::shared_ptr<copra::PreviewSystem> previewSystem_ =
278 std::shared_ptr<copra::TrajectoryConstraint> termDCMCons_ =
nullptr;
279 std::shared_ptr<copra::TrajectoryConstraint> termZMPCons_ =
nullptr;
280 std::shared_ptr<copra::TrajectoryConstraint> zmpCons_ =
nullptr;
281 std::shared_ptr<copra::TrajectoryCost> velCost_ =
nullptr;
282 std::shared_ptr<copra::TrajectoryCost> zmpCost_ =
nullptr;
283 unsigned indexToHrep_[
NB_STEPS + 1];
284 unsigned nbDoubleSupportSteps_ = 0;
286 unsigned nbInitSupportSteps_ =
288 unsigned nbNextDoubleSupportSteps_ =
290 unsigned nbTargetSupportSteps_ =
std::pair< Eigen::MatrixXd, Eigen::VectorXd > HrepXd
mc_planning::Pendulum Pendulum
unsigned nbDoubleSupportSteps() const
void contacts(Contact initContact, Contact targetContact, Contact nextContact)
void addLogEntries(mc_rtc::Logger &logger)
unsigned indexToHrep(unsigned i) const
void addGUIElements(std::shared_ptr< mc_rtc::gui::StateBuilder > gui)
const Contact & nextContact() const
const std::shared_ptr< Preview > solution() const
void initState(const mc_planning::Pendulum &pendulum)
static constexpr EIGEN_MAKE_ALIGNED_OPERATOR_NEW double SAMPLING_PERIOD
void comHeight(double height)
static constexpr unsigned INPUT_SIZE
const Contact & targetContact() const
void configure(const mc_rtc::Configuration &)
unsigned nbInitSupportSteps() const
void sole(const Sole &sole)
void phaseDurations(double initSupportDuration, double doubleSupportDuration, double targetSupportDuration)
Eigen::Vector2d velWeights
const Contact & initContact() const
static constexpr unsigned NB_STEPS
static constexpr unsigned STATE_SIZE