robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
split_riccati_factorization.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_SPLIT_RICCATI_FACTORIZATION_HXX_
2#define ROBOTOC_SPLIT_RICCATI_FACTORIZATION_HXX_
3
5
6
7namespace robotoc {
8
10 : P(Eigen::MatrixXd::Zero(2*robot.dimv(), 2*robot.dimv())),
11 s(Eigen::VectorXd::Zero(2*robot.dimv())),
12 psi_x(Eigen::VectorXd::Zero(2*robot.dimv())),
13 psi_u(Eigen::VectorXd::Zero(robot.dimu())),
14 Psi(Eigen::VectorXd::Zero(2*robot.dimv())),
15 phi_x(Eigen::VectorXd::Zero(2*robot.dimv())),
16 phi_u(Eigen::VectorXd::Zero(robot.dimu())),
17 Phi(Eigen::VectorXd::Zero(2*robot.dimv())),
18 xi(0.0),
19 chi(0.0),
20 rho(0.0),
21 eta(0.0),
22 iota(0.0),
23 M_full_(Eigen::MatrixXd::Zero(robot.max_dimf(), 2*robot.dimv())),
24 m_full_(Eigen::VectorXd::Zero(robot.max_dimf())),
25 mt_full_(Eigen::VectorXd::Zero(robot.max_dimf())),
26 mt_next_full_(Eigen::VectorXd::Zero(robot.max_dimf())),
27 dimv_(robot.dimv()),
28 dimx_(2*robot.dimv()),
29 dims_(0) {
30}
31
32
34 : P(),
35 s(),
36 psi_x(),
37 psi_u(),
38 Psi(),
39 phi_x(),
40 phi_u(),
41 Phi(),
42 xi(0.0),
43 chi(0.0),
44 rho(0.0),
45 eta(0.0),
46 iota(0.0),
47 M_full_(),
48 m_full_(),
49 mt_full_(),
50 mt_next_full_(),
51 dimv_(0),
52 dimx_(0),
53 dims_(0) {
54}
55
56
58}
59
60
62 assert(dims >= 0);
63 assert(dims <= m_full_.size());
64 dims_ = dims;
65}
66
67
69 return dims_;
70}
71
72
73inline Eigen::Block<Eigen::MatrixXd> SplitRiccatiFactorization::M() {
74 return M_full_.topLeftCorner(dims_, dimx_);
75}
76
77
78inline const Eigen::Block<const Eigen::MatrixXd> SplitRiccatiFactorization::M() const {
79 return M_full_.topLeftCorner(dims_, dimx_);
80}
81
82
83inline Eigen::VectorBlock<Eigen::VectorXd> SplitRiccatiFactorization::m() {
84 return m_full_.head(dims_);
85}
86
87
88inline const Eigen::VectorBlock<const Eigen::VectorXd> SplitRiccatiFactorization::m() const {
89 return m_full_.head(dims_);
90}
91
92
93inline Eigen::VectorBlock<Eigen::VectorXd> SplitRiccatiFactorization::mt() {
94 return mt_full_.head(dims_);
95}
96
97
98inline const Eigen::VectorBlock<const Eigen::VectorXd> SplitRiccatiFactorization::mt() const {
99 return mt_full_.head(dims_);
100}
101
102
103inline Eigen::VectorBlock<Eigen::VectorXd> SplitRiccatiFactorization::mt_next() {
104 return mt_next_full_.head(dims_);
105}
106
107
108inline const Eigen::VectorBlock<const Eigen::VectorXd> SplitRiccatiFactorization::mt_next() const {
109 return mt_next_full_.head(dims_);
110}
111
112
114 P.setZero();
115 s.setZero();
116 psi_x.setZero();
117 psi_u.setZero();
118 Psi.setZero();
119 phi_x.setZero();
120 phi_u.setZero();
121 Phi.setZero();
122 xi = 0;
123 chi = 0;
124 rho = 0;
125 eta = 0;
126 iota = 0;
127 M_full_.setZero();
128 m_full_.setZero();
129 mt_full_.setZero();
130 mt_next_full_.setZero();
131}
132
133
135 P.setRandom();
136 s.setRandom();
137 psi_x.setRandom();
138 psi_u.setRandom();
139 Psi.setRandom();
140 phi_x.setRandom();
141 phi_u.setRandom();
142 Phi.setRandom();
143 const Eigen::VectorXd vec = Eigen::VectorXd::Random(5);
144 xi = vec[0];
145 chi = vec[1];
146 rho = vec[2];
147 eta = vec[3];
148 iota = vec[4];
149 M_full_.setRandom();
150 m_full_.setRandom();
151 mt_full_.setRandom();
152 mt_next_full_.setRandom();
153}
154
155
157 const SplitRiccatiFactorization& other) const {
158 if (!P.isApprox(other.P)) return false;
159 if (!s.isApprox(other.s)) return false;
160 if (!psi_x.isApprox(other.psi_x)) return false;
161 if (!psi_u.isApprox(other.psi_u)) return false;
162 if (!Psi.isApprox(other.Psi)) return false;
163 if (!phi_x.isApprox(other.phi_x)) return false;
164 if (!phi_u.isApprox(other.phi_u)) return false;
165 if (!Phi.isApprox(other.Phi)) return false;
166 Eigen::VectorXd vec(5), other_vec(5);
167 vec << xi, chi, rho, eta, iota;
168 other_vec << other.xi, other.chi, other.rho, other.eta, other.iota;
169 if (!vec.isApprox(other_vec)) return false;
170 if (dims() > 0) {
171 if (!M().isApprox(other.M())) return false;
172 if (!m().isApprox(other.m())) return false;
173 if (!mt().isApprox(other.mt())) return false;
174 if (!mt_next().isApprox(other.mt_next())) return false;
175 }
176 return true;
177}
178
179
181 if (P.hasNaN()) return true;
182 if (s.hasNaN()) return true;
183 if (psi_x.hasNaN()) return true;
184 if (psi_u.hasNaN()) return true;
185 if (Psi.hasNaN()) return true;
186 if (phi_x.hasNaN()) return true;
187 if (phi_u.hasNaN()) return true;
188 if (Phi.hasNaN()) return true;
189 Eigen::VectorXd vec(5);
190 vec << xi, chi, rho, eta, iota;
191 if (vec.hasNaN()) return true;
192 if (dims() > 0) {
193 if (M().hasNaN()) return true;
194 if (m().hasNaN()) return true;
195 if (mt().hasNaN()) return true;
196 if (mt_next().hasNaN()) return true;
197 }
198 return false;
199}
200
201
203 const Robot& robot) {
204 auto riccati = SplitRiccatiFactorization(robot);
205 riccati.setRandom();
206 return riccati;
207}
208
209} // namespace robotoc
210
211#endif // ROBOTOC_SPLIT_RICCATI_FACTORIZATION_HXX_
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
Riccati factorization matrix and vector for a time stage.
Definition: split_riccati_factorization.hpp:15
double iota
Riccati factorization w.r.t. the switching time.
Definition: split_riccati_factorization.hpp:174
double rho
Riccati factorization w.r.t. the switching time.
Definition: split_riccati_factorization.hpp:164
int dims() const
Definition: split_riccati_factorization.hxx:68
Eigen::VectorXd psi_x
Riccati factorization vector w.r.t. the switching time. Size is 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:119
Eigen::VectorXd Phi
Riccati factorization vector w.r.t. the switching time. Size is 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:149
Eigen::VectorBlock< Eigen::VectorXd > mt()
Definition: split_riccati_factorization.hxx:93
void setRandom()
Definition: split_riccati_factorization.hxx:134
double chi
Riccati factorization w.r.t. the switching time.
Definition: split_riccati_factorization.hpp:159
Eigen::Block< Eigen::MatrixXd > M()
Definition: split_riccati_factorization.hxx:73
bool hasNaN() const
Checks this object has at least one NaN.
Definition: split_riccati_factorization.hxx:180
void setConstraintDimension(const int dims=0)
Definition: split_riccati_factorization.hxx:61
Eigen::VectorBlock< Eigen::VectorXd > mt_next()
Definition: split_riccati_factorization.hxx:103
Eigen::VectorXd psi_u
Riccati factorization vector w.r.t. the switching time. Size is Robot::dimu().
Definition: split_riccati_factorization.hpp:125
~SplitRiccatiFactorization()
Destructor.
Definition: split_riccati_factorization.hxx:57
Eigen::VectorXd Psi
Riccati factorization vector w.r.t. the switching time. Size is 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:131
static SplitRiccatiFactorization Random(const Robot &robot)
Definition: split_riccati_factorization.hxx:202
Eigen::VectorBlock< Eigen::VectorXd > m()
Definition: split_riccati_factorization.hxx:83
Eigen::MatrixXd P
Riccati factorization matrix. Size is 2 * Robot::dimv() x 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:60
bool isApprox(const SplitRiccatiFactorization &other) const
Checks the equivalence of two SplitRiccatiFactorization.
Definition: split_riccati_factorization.hxx:156
double xi
Riccati factorization w.r.t. the switching time.
Definition: split_riccati_factorization.hpp:154
Eigen::VectorXd phi_u
Riccati factorization vector w.r.t. the switching time. Size is Robot::dimu().
Definition: split_riccati_factorization.hpp:143
Eigen::VectorXd phi_x
Riccati factorization vector w.r.t. the switching time. Size is 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:137
Eigen::VectorXd s
Riccati factorization vector. Size is 2 * Robot::dimv().
Definition: split_riccati_factorization.hpp:65
void setZero()
Definition: split_riccati_factorization.hxx:113
SplitRiccatiFactorization()
Default constructor.
Definition: split_riccati_factorization.hxx:33
double eta
Riccati factorization w.r.t. the switching time.
Definition: split_riccati_factorization.hpp:169
Definition: constraint_component_base.hpp:17