robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
split_solution.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_SPLIT_SOLUTION_HPP_
2#define ROBOTOC_SPLIT_SOLUTION_HPP_
3
4#include <vector>
5#include <iostream>
6
7#include "Eigen/Core"
8
12
13
14namespace robotoc {
15
21public:
22 using Vector6d = Eigen::Matrix<double, 6, 1>;
23
28 SplitSolution(const Robot& robot);
29
34
38 ~SplitSolution() = default;
39
43 SplitSolution(const SplitSolution&) = default;
44
49
53 SplitSolution(SplitSolution&&) noexcept = default;
54
58 SplitSolution& operator=(SplitSolution&&) noexcept = default;
59
64 void setContactStatus(const ContactStatus& contact_status);
65
70 void setContactStatus(const ImpactStatus& contact_status);
71
76 void setContactStatus(const SplitSolution& other);
77
83
87 Eigen::VectorXd q;
88
92 Eigen::VectorXd v;
93
98 Eigen::VectorXd a;
99
104 Eigen::VectorXd dv;
105
109 Eigen::VectorXd u;
110
116 std::vector<Vector6d> f;
117
122 Eigen::VectorBlock<Eigen::VectorXd> f_stack();
123
127 const Eigen::VectorBlock<const Eigen::VectorXd> f_stack() const;
128
132 void set_f_stack();
133
137 void set_f_vector();
138
143 Eigen::VectorXd lmd;
144
149 Eigen::VectorXd gmm;
150
155 Eigen::VectorXd beta;
156
163 std::vector<Vector6d> mu;
164
169 Eigen::VectorXd nu_passive;
170
178 Eigen::VectorBlock<Eigen::VectorXd> mu_stack();
179
183 const Eigen::VectorBlock<const Eigen::VectorXd> mu_stack() const;
184
188 void set_mu_stack();
189
193 void set_mu_vector();
194
202 Eigen::VectorBlock<Eigen::VectorXd> xi_stack();
203
207 const Eigen::VectorBlock<const Eigen::VectorXd> xi_stack() const;
208
213 int dimf() const;
214
219 int dims() const;
220
226 bool isContactActive(const int contact_index) const;
227
232 std::vector<bool> isContactActive() const;
233
241 void integrate(const Robot& robot, const double step_size,
242 const SplitDirection& d, const bool impact=false);
243
248 void copyPrimal(const SplitSolution& other);
249
254 void copyDual(const SplitSolution& other);
255
261 bool isApprox(const SplitSolution& other) const;
262
268
274 void setRandom(const Robot& robot);
275
281 void setRandom(const Robot& robot, const ContactStatus& contact_status);
282
288 void setRandom(const Robot& robot, const ImpactStatus& impact_status);
289
297 void setRandom(const Robot& robot, const ContactStatus& contact_status,
298 const ImpactStatus& impact_status);
299
305 static SplitSolution Random(const Robot& robot);
306
313 static SplitSolution Random(const Robot& robot,
314 const ContactStatus& contact_status);
315
322 static SplitSolution Random(const Robot& robot,
323 const ImpactStatus& impact_status);
324
332 static SplitSolution Random(const Robot& robot,
333 const ContactStatus& contact_status,
334 const ImpactStatus& impact_status);
335
339 void disp(std::ostream& os) const;
340
341 friend std::ostream& operator<<(std::ostream& os, const SplitSolution& s);
342
343private:
344 Eigen::VectorXd mu_stack_, f_stack_, xi_stack_;
345 bool has_floating_base_;
346 std::vector<ContactType> contact_types_;
347 std::vector<bool> is_contact_active_;
348 int dimf_, dims_, max_num_contacts_;
349
350};
351
352} // namespace robotoc
353
354#include "robotoc/core/split_solution.hxx"
355
356#endif // ROBOTOC_SPLIT_SOLUTION_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
Newton direction of the solution to the optimal control problem split into a time stage.
Definition: split_direction.hpp:20
Solution to the optimal control problem split into a time stage.
Definition: split_solution.hpp:20
Eigen::VectorBlock< Eigen::VectorXd > f_stack()
Stack of the active contact forces. Size is ContactStatus::dimf().
Definition: split_solution.hxx:40
Eigen::VectorBlock< Eigen::VectorXd > xi_stack()
Stack of the Lagrange multipliers w.r.t. the switching constraints that is active at the future impac...
Definition: split_solution.hxx:146
SplitSolution(const Robot &robot)
Construct a split solution.
SplitSolution()
Default constructor.
void disp(std::ostream &os) const
Displays the split solution onto a ostream.
void setRandom(const Robot &robot)
Set each component vector by random value based on the current contact status.
void set_f_stack()
Sets SplitSolution::f_stack() from SplitSolution::f.
Definition: split_solution.hxx:51
Eigen::VectorXd u
Control input torques. Size is Robot::dimu().
Definition: split_solution.hpp:109
void integrate(const Robot &robot, const double step_size, const SplitDirection &d, const bool impact=false)
Integrates the solution based on step size and direction.
Eigen::VectorXd q
Configuration. Size is Robot::dimq().
Definition: split_solution.hpp:87
int dimf() const
Returns the dimension of the contact at the current contact status.
Definition: split_solution.hxx:157
double lagrangeMultiplierLinfNorm() const
Return L-infinity Norm of the lagrange multipliers. Used in line search.
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: split_solution.hpp:22
Eigen::VectorXd dv
Generalized acceleration. Size is Robot::dimv().
Definition: split_solution.hpp:104
Eigen::VectorXd beta
Lagrange multiplier w.r.t. the inverse dynamics constraint. Size is Robot::dimv().
Definition: split_solution.hpp:155
SplitSolution & operator=(const SplitSolution &)=default
Default copy assign operator.
int dims() const
Returns the dimension of the switching constraint.
Definition: split_solution.hxx:162
Eigen::VectorXd gmm
Lagrange multiplier w.r.t. the state equation w.r.t. v. Size is Robot::dimv().
Definition: split_solution.hpp:149
void setSwitchingConstraintDimension(const int dims)
Sets the dimension of the switching constraint.
Definition: split_solution.hxx:33
std::vector< bool > isContactActive() const
Return activities of contacts.
Definition: split_solution.hxx:175
void set_mu_vector()
Set SplitSolution::mu from SplitSolution::mu_stack().
Definition: split_solution.hxx:125
Eigen::VectorXd v
Generalized velocity. Size is Robot::dimv().
Definition: split_solution.hpp:92
Eigen::VectorBlock< Eigen::VectorXd > mu_stack()
Stack of the Lagrange multipliers w.r.t. the acceleration-level contact constraints that is active at...
Definition: split_solution.hxx:93
void set_mu_stack()
Set SplitSolution::mu_stack() from SplitSolution::mu.
Definition: split_solution.hxx:104
void copyDual(const SplitSolution &other)
Copies the dual solution from another solution.
bool isApprox(const SplitSolution &other) const
Return true if two SplitSolution have the same value and false if not.
Eigen::VectorXd lmd
Lagrange multiplier w.r.t. the state equation w.r.t. q. Size is Robot::dimv().
Definition: split_solution.hpp:143
Eigen::VectorXd a
Generalized acceleration. Size is Robot::dimv().
Definition: split_solution.hpp:98
void set_f_vector()
Sets SplitSolution::f from SplitSolution::f_stack().
Definition: split_solution.hxx:72
~SplitSolution()=default
Default destructor.
static SplitSolution Random(const Robot &robot)
Generates split solution filled randomly.
std::vector< Vector6d > mu
Lagrange multiplier w.r.t. the acceleration-level contact constraint. Upper 3 elements are w....
Definition: split_solution.hpp:163
void setContactStatus(const ContactStatus &contact_status)
Set contact status, i.e., set the dimension of the contacts.
Definition: split_solution.hxx:10
SplitSolution(const SplitSolution &)=default
Default copy constructor.
Eigen::VectorXd nu_passive
Lagrange multiplier w.r.t. the passive joint constraint. Size is Robot::dim_passive().
Definition: split_solution.hpp:169
std::vector< Vector6d > f
Contact wrenches. Upper 3 elements are linear contact force and the lower 3 elements are the angular ...
Definition: split_solution.hpp:116
void copyPrimal(const SplitSolution &other)
Copies the primal solution from another solution.
SplitSolution(SplitSolution &&) noexcept=default
Default move constructor.
Definition: constraint_component_base.hpp:17
ContactType
Types of contacts.
Definition: contact_status.hpp:22