robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
split_kkt_residual.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_SPLIT_KKT_RESIDUAL_HPP_
2#define ROBOTOC_SPLIT_KKT_RESIDUAL_HPP_
3
4#include <iostream>
5
6#include "Eigen/Core"
7
10
11
12namespace robotoc {
13
19public:
24 SplitKKTResidual(const Robot& robot);
25
30
34 ~SplitKKTResidual() = default;
35
40
45
49 SplitKKTResidual(SplitKKTResidual&&) noexcept = default;
50
54 SplitKKTResidual& operator=(SplitKKTResidual&&) noexcept = default;
55
60 void setContactDimension(const int dimf);
61
67
71 Eigen::VectorXd Fx;
72
78 Eigen::VectorBlock<Eigen::VectorXd> Fq();
79
83 const Eigen::VectorBlock<const Eigen::VectorXd> Fq() const;
84
90 Eigen::VectorBlock<Eigen::VectorXd> Fv();
91
95 const Eigen::VectorBlock<const Eigen::VectorXd> Fv() const;
96
102 Eigen::VectorBlock<Eigen::VectorXd> P();
103
107 const Eigen::VectorBlock<const Eigen::VectorXd> P() const;
108
112 Eigen::VectorXd lx;
113
118 Eigen::VectorBlock<Eigen::VectorXd> lq();
119
123 const Eigen::VectorBlock<const Eigen::VectorXd> lq() const;
124
129 Eigen::VectorBlock<Eigen::VectorXd> lv();
130
134 const Eigen::VectorBlock<const Eigen::VectorXd> lv() const;
135
139 Eigen::VectorXd la;
140
145 Eigen::VectorXd ldv;
146
151 Eigen::VectorXd lu;
152
158 Eigen::VectorBlock<Eigen::VectorXd> lf();
159
163 const Eigen::VectorBlock<const Eigen::VectorXd> lf() const;
164
169 double h;
170
176 double KKTError() const;
177
185 template <int p=1>
186 double primalFeasibility() const;
187
195 template <int p=1>
196 double dualFeasibility() const;
197
201 void setZero();
202
208 int dimf() const;
209
215 int dims() const;
216
222
228 bool isApprox(const SplitKKTResidual& other) const;
229
234 bool hasNaN() const;
235
239 void setRandom();
240
245 void setRandom(const ContactStatus& contact_status);
246
251 void setRandom(const ImpactStatus& impact_status);
252
258 static SplitKKTResidual Random(const Robot& robot);
259
266 static SplitKKTResidual Random(const Robot& robot,
267 const ContactStatus& contact_status);
268
275 static SplitKKTResidual Random(const Robot& robot,
276 const ImpactStatus& impact_status);
277
281 void disp(std::ostream& os) const;
282
283 friend std::ostream& operator<<(std::ostream& os,
284 const SplitKKTResidual& kkt_residual);
285
286private:
287 Eigen::VectorXd P_full_, lf_full_;
288 int dimv_, dimu_, dimf_, dims_;
289
290};
291
292} // namespace robotoc
293
294#include "robotoc/core/split_kkt_residual.hxx"
295
296#endif // ROBOTOC_SPLIT_KKT_RESIDUAL_HPP_
Contact status of robot model.
Definition: contact_status.hpp:32
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
KKT residual split into each time stage.
Definition: split_kkt_residual.hpp:18
SplitKKTResidual(SplitKKTResidual &&) noexcept=default
Default move constructor.
SplitKKTResidual(const SplitKKTResidual &)=default
Default copy constructor.
void disp(std::ostream &os) const
Displays the split KKT residual onto a ostream.
SplitKKTResidual & operator=(const SplitKKTResidual &)=default
Default copy operator.
Eigen::VectorBlock< Eigen::VectorXd > Fq()
Residual in the state equation w.r.t. the configuration q.
Definition: split_kkt_residual.hxx:25
Eigen::VectorXd lu
KKT residual w.r.t. the control input torques u. Size is Robot::dimu().
Definition: split_kkt_residual.hpp:151
Eigen::VectorBlock< Eigen::VectorXd > lf()
KKT residual w.r.t. the stack of the contact forces f.
Definition: split_kkt_residual.hxx:79
double dualFeasibility() const
Returns the lp norm of the dual feasibility. Default norm is l1-norm. You can also specify l-infty no...
Definition: split_kkt_residual.hxx:118
double KKTError() const
Returns the squared norm of the KKT residual, that is, the primal and dual residual.
Definition: split_kkt_residual.hxx:90
static SplitKKTResidual Random(const Robot &robot)
Generates split KKT residual filled randomly.
void setSwitchingConstraintDimension(const int dims)
Sets the dimension of the switching constraint.
Definition: split_kkt_residual.hxx:18
SplitKKTResidual(const Robot &robot)
Construct a split KKT residual.
Eigen::VectorBlock< Eigen::VectorXd > lv()
KKT residual w.r.t. the joint velocity v.
Definition: split_kkt_residual.hxx:68
bool hasNaN() const
Checks this has at least one NaN.
Eigen::VectorBlock< Eigen::VectorXd > Fv()
Residual in the state equation w.r.t. the velocity v.
Definition: split_kkt_residual.hxx:36
bool isApprox(const SplitKKTResidual &other) const
Checks the equivalence of two SplitKKTResidual.
void setContactDimension(const int dimf)
Sets contact status, i.e., set dimension of the contact forces.
Definition: split_kkt_residual.hxx:11
bool isDimensionConsistent() const
Checks dimensional consistency of each component.
Eigen::VectorBlock< Eigen::VectorXd > P()
Residual in the switching constraint.
Definition: split_kkt_residual.hxx:47
void setRandom()
Set by random value based on the current contact status.
Eigen::VectorXd ldv
KKT residual w.r.t. the impact change in the velocity ddv. Size is Robot::dimv().
Definition: split_kkt_residual.hpp:145
Eigen::VectorXd Fx
Residual in the state equation. Size is 2 * Robot::dimv().
Definition: split_kkt_residual.hpp:71
SplitKKTResidual()
Default constructor.
double primalFeasibility() const
Returns the lp norm of the primal feasibility, i.e., the constraint violation. Default norm is l1-nor...
Definition: split_kkt_residual.hxx:108
int dims() const
Returns the dimension of the stack of the contact forces at the current contact status.
Definition: split_kkt_residual.hxx:151
Eigen::VectorXd lx
KKT Residual w.r.t. the state x. Size is 2 * Robot::dimv().
Definition: split_kkt_residual.hpp:112
Eigen::VectorBlock< Eigen::VectorXd > lq()
KKT residual w.r.t. the configuration q.
Definition: split_kkt_residual.hxx:57
~SplitKKTResidual()=default
Default destructor.
void setZero()
Sets the split KKT residual zero.
Definition: split_kkt_residual.hxx:130
double h
KKT residual w.r.t. the switching time, that is, this is the value of the Hamiltonian.
Definition: split_kkt_residual.hpp:169
int dimf() const
Returns the dimension of the stack of the contact forces at the current contact status.
Definition: split_kkt_residual.hxx:146
Eigen::VectorXd la
KKT residual w.r.t. the acceleration a. Size is Robot::dimv().
Definition: split_kkt_residual.hpp:139
Definition: constraint_component_base.hpp:17