robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
lqr_policy.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_LQR_POLICY_HPP_
2#define ROBOTOC_LQR_POLICY_HPP_
3
4#include "Eigen/Core"
5
7
8
9namespace robotoc {
10
16class LQRPolicy {
17public:
19 = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
20
25 LQRPolicy(const Robot& robot)
26 : K(MatrixXdRowMajor::Zero(robot.dimu(), 2*robot.dimv())),
27 k(Eigen::VectorXd::Zero(robot.dimu())),
28 T(Eigen::VectorXd::Zero(robot.dimu())),
29 W(Eigen::VectorXd::Zero(robot.dimu())),
30 dimv_(robot.dimv()),
31 dimu_(robot.dimu()) {
32 }
33
38 : K(),
39 k(),
40 T(),
41 W(),
42 dimv_(0),
43 dimu_(0) {
44 }
45
50 }
51
55 LQRPolicy(const LQRPolicy&) = default;
56
60 LQRPolicy& operator=(const LQRPolicy&) = default;
61
65 LQRPolicy(LQRPolicy&&) noexcept = default;
66
70 LQRPolicy& operator=(LQRPolicy&&) noexcept = default;
71
77
81 Eigen::VectorXd k;
82
86 Eigen::VectorXd T;
87
91 Eigen::VectorXd W;
92
98 const Eigen::Block<const MatrixXdRowMajor> Kq() const {
99 return K.topLeftCorner(dimu_, dimv_);
100 }
101
107 const Eigen::Block<const MatrixXdRowMajor> Kv() const {
108 return K.topRightCorner(dimu_, dimv_);
109 }
110
116 bool isApprox(const LQRPolicy& other) const {
117 if (!K.isApprox(other.K)) return false;
118 if (!k.isApprox(other.k)) return false;
119 if (!T.isApprox(other.T)) return false;
120 if (!W.isApprox(other.W)) return false;
121 return true;
122 }
123
124private:
125 int dimv_, dimu_;
126
127};
128
129} // namespace robotoc
130
131#endif // ROBOTOC_LQR_POLICY_HPP_
The state feedback and feedforward policy of LQR subproblem at a time stage.
Definition: lqr_policy.hpp:16
MatrixXdRowMajor K
State feedback gain matrix. Size is Robot::dimu() x 2 * Robot::dimv().
Definition: lqr_policy.hpp:76
LQRPolicy & operator=(const LQRPolicy &)=default
Default copy operator.
const Eigen::Block< const MatrixXdRowMajor > Kq() const
State feedback gain matrix w.r.t. the configuration q. Size is Robot::dimu() x Robot::dimv().
Definition: lqr_policy.hpp:98
LQRPolicy(const LQRPolicy &)=default
Default copy constructor.
LQRPolicy(const Robot &robot)
Constructs LQR gain and feedforward term.
Definition: lqr_policy.hpp:25
Eigen::VectorXd k
Feedforward term. Size is Robot::dimu().
Definition: lqr_policy.hpp:81
Eigen::VectorXd W
Feedback gain w.r.t the next switching time. Size is Robot::dimu().
Definition: lqr_policy.hpp:91
LQRPolicy()
Default constructor.
Definition: lqr_policy.hpp:37
~LQRPolicy()
Destructor.
Definition: lqr_policy.hpp:49
bool isApprox(const LQRPolicy &other) const
Checks the equivalence of two LQRPolicy.
Definition: lqr_policy.hpp:116
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXdRowMajor
Definition: lqr_policy.hpp:19
LQRPolicy(LQRPolicy &&) noexcept=default
Default move constructor.
Eigen::VectorXd T
Feedback gain w.r.t the switching time. Size is Robot::dimu().
Definition: lqr_policy.hpp:86
const Eigen::Block< const MatrixXdRowMajor > Kv() const
State feedback gain matrix w.r.t. the velocity v. Size is Robot::dimu() x Robot::dimv().
Definition: lqr_policy.hpp:107
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
Definition: constraint_component_base.hpp:17