MIMPC++
A fast typesafe Mixed Integer MPC C++ library
MPC.hpp
1 #pragma once
2 
3 #include "Solver.hpp"
4 #include <type_traits>
5 #include <concepts>
6 
7 namespace mimpc {
14  template<class SystemType, class SolverType> requires
15  std::derived_from<SystemType, System<SystemType::NUM_STATES, SystemType::NUM_CONT_INPUTS, SystemType::NUM_BIN_INPUTS>> &&
16  std::derived_from<SolverType, Solver<SystemType, SolverType::PRED_STEPS, SolverType::MIN_STEPS_ON, SolverType::MIN_STEPS_OFF, SolverType::MAX_STEPS_ON, SolverType::NUM_STEPS_SOLVER_DELAY, SolverType::INTEGRATION_SCHEME>>
17  class MPC {
18  public:
19  using SYSTEM_TYPE = SystemType;
20  using SOLVER_TYPE = SolverType;
21  private:
22  SolverType &solver_;
23  Eigen::Matrix<double, SystemType::NUM_STATES, SolverType::PRED_STEPS + 1, Eigen::RowMajor> last_x_;
24  Eigen::Matrix<double, SystemType::NUM_CONT_INPUTS +
25  SystemType::NUM_BIN_INPUTS, SolverType::PRED_STEPS, Eigen::RowMajor> last_u_;
26  Eigen::Matrix<double,
27  SystemType::NUM_CONT_INPUTS + SystemType::NUM_BIN_INPUTS,
28  SolverType::history_depth + SolverType::NUM_STEPS_SOLVER_DELAY> history_;
29  public:
35  explicit MPC(SolverType &solver);
36 
46  SOLVER_RETURN control(const SystemType::StateVec &state, SystemType::InputVec &input, std::string &stats);
47 
48  virtual ~MPC() = default;
49  };
50 };
51 
52 #include "MPC.tpp"
Abstract class that represents any solver interface and provides a low-lever mpc solver interface.
SOLVER_RETURN
Definition: Solver.hpp:18
Definition: MPC.hpp:17
SOLVER_RETURN control(const SystemType::StateVec &state, SystemType::InputVec &input, std::string &stats)
MPC(SolverType &solver)