robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
split_solution.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_SPLIT_SOLUTION_HXX_
2#define ROBOTOC_SPLIT_SOLUTION_HXX_
3
5
6#include <cassert>
7
8namespace robotoc {
9
11 const ContactStatus& contact_status) {
12 assert(contact_status.maxNumContacts() == is_contact_active_.size());
13 is_contact_active_ = contact_status.isContactActive();
14 dimf_ = contact_status.dimf();
15}
16
17
19 const ImpactStatus& contact_status) {
20 assert(contact_status.maxNumContacts() == is_contact_active_.size());
21 is_contact_active_ = contact_status.isImpactActive();
22 dimf_ = contact_status.dimf();
23}
24
25
27 assert(other.isContactActive().size() == is_contact_active_.size());
28 is_contact_active_ = other.isContactActive();
29 dimf_ = other.dimf();
30}
31
32
34 assert(dims >= 0);
35 assert(dims <= xi_stack_.size());
36 dims_ = std::max(dims, 0);
37}
38
39
40inline Eigen::VectorBlock<Eigen::VectorXd> SplitSolution::f_stack() {
41 return f_stack_.head(dimf_);
42}
43
44
45inline const Eigen::VectorBlock<const Eigen::VectorXd>
47 return f_stack_.head(dimf_);
48}
49
50
52 int segment_begin = 0;
53 for (int i=0; i<max_num_contacts_; ++i) {
54 if (is_contact_active_[i]) {
55 switch (contact_types_[i]) {
57 f_stack_.template segment<3>(segment_begin) = f[i].template head<3>();
58 segment_begin += 3;
59 break;
61 f_stack_.template segment<6>(segment_begin) = f[i];
62 segment_begin += 6;
63 break;
64 default:
65 break;
66 }
67 }
68 }
69}
70
71
73 int segment_begin = 0;
74 for (int i=0; i<max_num_contacts_; ++i) {
75 if (is_contact_active_[i]) {
76 switch (contact_types_[i]) {
78 f[i].template head<3>() = f_stack_.template segment<3>(segment_begin);
79 segment_begin += 3;
80 break;
82 f[i] = f_stack_.template segment<6>(segment_begin);
83 segment_begin += 6;
84 break;
85 default:
86 break;
87 }
88 }
89 }
90}
91
92
93inline Eigen::VectorBlock<Eigen::VectorXd> SplitSolution::mu_stack() {
94 return mu_stack_.head(dimf_);
95}
96
97
98inline const Eigen::VectorBlock<const Eigen::VectorXd>
100 return mu_stack_.head(dimf_);
101}
102
103
105 int segment_begin = 0;
106 for (int i=0; i<max_num_contacts_; ++i) {
107 if (is_contact_active_[i]) {
108 switch (contact_types_[i]) {
110 mu_stack_.template segment<3>(segment_begin) = mu[i].template head<3>();
111 segment_begin += 3;
112 break;
114 mu_stack_.template segment<6>(segment_begin) = mu[i];
115 segment_begin += 6;
116 break;
117 default:
118 break;
119 }
120 }
121 }
122}
123
124
126 int segment_begin = 0;
127 for (int i=0; i<max_num_contacts_; ++i) {
128 if (is_contact_active_[i]) {
129 switch (contact_types_[i]) {
131 mu[i].template head<3>() = mu_stack_.template segment<3>(segment_begin);
132 segment_begin += 3;
133 break;
135 mu[i] = mu_stack_.template segment<6>(segment_begin);
136 segment_begin += 6;
137 break;
138 default:
139 break;
140 }
141 }
142 }
143}
144
145
146inline Eigen::VectorBlock<Eigen::VectorXd> SplitSolution::xi_stack() {
147 return xi_stack_.head(dims_);
148}
149
150
151inline const Eigen::VectorBlock<const Eigen::VectorXd>
153 return xi_stack_.head(dims_);
154}
155
156
157inline int SplitSolution::dimf() const {
158 return dimf_;
159}
160
161
162inline int SplitSolution::dims() const {
163 return dims_;
164}
165
166
167inline bool SplitSolution::isContactActive(const int contact_index) const {
168 assert(!is_contact_active_.empty());
169 assert(contact_index >= 0);
170 assert(contact_index < is_contact_active_.size());
171 return is_contact_active_[contact_index];
172}
173
174
175inline std::vector<bool> SplitSolution::isContactActive() const {
176 return is_contact_active_;
177}
178
179} // namespace robotoc
180
181#endif // ROBOTOC_SPLIT_SOLUTION_HXX_
Contact status of robot model.
Definition: contact_status.hpp:32
bool isContactActive(const int contact_index) const
Returns true if a contact is active and false if not.
Definition: contact_status.hxx:101
int maxNumContacts() const
Returns the maximum number of the contacts.
Definition: contact_status.hxx:130
int dimf() const
Returns the dimension of the active contact forces.
Definition: contact_status.hxx:125
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
int dimf() const
Returns the dimension of the active impact forces.
Definition: impact_status.hxx:70
int maxNumContacts() const
Returns the maximum number of the contacts.
Definition: impact_status.hxx:75
bool isImpactActive(const int contact_index) const
Returns true if a contact is active and false if not.
Definition: impact_status.hxx:55
Solution to the optimal control problem split into a time stage.
Definition: split_solution.hpp:20
bool isContactActive(const int contact_index) const
Return true if contact is active and false if not.
Definition: split_solution.hxx:167
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
void set_f_stack()
Sets SplitSolution::f_stack() from SplitSolution::f.
Definition: split_solution.hxx:51
int dimf() const
Returns the dimension of the contact at the current contact status.
Definition: split_solution.hxx:157
int dims() const
Returns the dimension of the switching constraint.
Definition: split_solution.hxx:162
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::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 set_f_vector()
Sets SplitSolution::f from SplitSolution::f_stack().
Definition: split_solution.hxx:72
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
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
Definition: constraint_component_base.hpp:17