MIMPC++
A fast typesafe Mixed Integer MPC C++ library
MPCLeafSystem.hpp
1 #pragma once
2 
3 #include "drake/systems/framework/leaf_system.h"
4 #include "MPC.hpp"
5 #include "System.hpp"
6 
7 namespace mimpc::simulation {
8  template<class MPCType> requires std::derived_from<MPCType, MPC<typename MPCType::SYSTEM_TYPE, typename MPCType::SOLVER_TYPE>>
9  class MPCLeafSystem : public drake::systems::LeafSystem<double> {
10  public:
11 
12  MPCLeafSystem(MPCType &reacsaSolver, double control_dt,
13  const MPCType::SYSTEM_TYPE::StateVec &state_constraints_lb,
14  const MPCType::SYSTEM_TYPE::StateVec &state_constraints_ub);
15 
16  ~MPCLeafSystem() override;
17 
18  private:
19  MPCType &reacsa_solver_;
20  double control_dt_;
21  MPCType::SYSTEM_TYPE::StateVec state_constraints_lb_;
22  MPCType::SYSTEM_TYPE::StateVec state_constraints_ub_;
23 
24  drake::systems::InputPort<double> *plant_out_port_;
25  drake::systems::OutputPort<double> *mpc_time_port_;
26  drake::systems::OutputPort<double> *control_out_port_;
27  drake::systems::DiscreteStateIndex control_out_state_;
28  drake::systems::DiscreteStateIndex mpc_time_out_state_;
29 
30  drake::systems::EventStatus discreteUpdate(const drake::systems::Context<double> &context,
31  drake::systems::DiscreteValues<double> *discrete_state) const;
32 
33  };
34 }
35 #include "MPCLeafSystem.tpp"
Abstract class to represent system dynamics.
Definition: MPCLeafSystem.hpp:9