robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
impact_status.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_IMPACT_STATUS_HXX_
2#define ROBOTOC_IMPACT_STATUS_HXX_
3
5
6#include <cassert>
7#include <random>
8
9
10namespace robotoc {
11
13 const std::vector<ContactType>& contact_types,
14 const std::vector<std::string>& contact_frame_names,
15 const double default_friction_coefficients)
16 : contact_status_(contact_types, contact_frame_names,
17 default_friction_coefficients) {
18}
19
20
22 : contact_status_() {
23}
24
25
26inline bool ImpactStatus::operator==(const ImpactStatus& other) const {
27 assert(other.maxNumContacts() == maxNumContacts());
28 for (int i=0; i<maxNumContacts(); ++i) {
29 if (other.isImpactActive(i) != isImpactActive(i)) {
30 return false;
31 }
32 if (!other.contactPlacement(i).isApprox(contactPlacement(i))) {
33 return false;
34 }
35 }
36 return true;
37}
38
39
40inline bool ImpactStatus::operator!=(const ImpactStatus& other) const {
41 return !(*this == other);
42}
43
44
45inline ContactType ImpactStatus::contactType(const int contact_index) const {
46 return contact_status_.contactType(contact_index);
47}
48
49
50inline const std::vector<ContactType>& ImpactStatus::contactTypes() const {
51 return contact_status_.contactTypes();
52}
53
54
55inline bool ImpactStatus::isImpactActive(const int contact_index) const {
56 return contact_status_.isContactActive(contact_index);
57}
58
59
60inline const std::vector<bool>& ImpactStatus::isImpactActive() const {
61 return contact_status_.isContactActive();
62}
63
64
65inline bool ImpactStatus::hasActiveImpact() const {
66 return contact_status_.hasActiveContacts();
67}
68
69
70inline int ImpactStatus::dimf() const {
71 return contact_status_.dimf();
72}
73
74
75inline int ImpactStatus::maxNumContacts() const {
76 return contact_status_.maxNumContacts();
77}
78
79
80inline void ImpactStatus::activateImpact(const int impact_index) {
81 contact_status_.activateContact(impact_index);
82}
83
84
85inline void ImpactStatus::deactivateImpact(const int impact_index) {
86 contact_status_.deactivateContact(impact_index);
87}
88
89
91 const std::vector<int>& impact_indices) {
92 contact_status_.activateContacts(impact_indices);
93}
94
95
97 const std::vector<int>& impact_indices) {
98 contact_status_.deactivateContacts(impact_indices);
99}
100
101
103 const int contact_index, const Eigen::Vector3d& contact_position) {
104 contact_status_.setContactPlacement(contact_index, contact_position);
105}
106
107
109 const int contact_index, const Eigen::Vector3d& contact_position,
110 const Eigen::Matrix3d& contact_rotation) {
111 contact_status_.setContactPlacement(contact_index, contact_position,
112 contact_rotation);
113}
114
115
116inline void ImpactStatus::setContactPlacement(const int contact_index,
117 const SE3& contact_placement) {
118 contact_status_.setContactPlacement(contact_index, contact_placement);
119}
120
121
123 const std::vector<Eigen::Vector3d>& contact_positions) {
124 contact_status_.setContactPlacements(contact_positions);
125}
126
127
129 const std::vector<Eigen::Vector3d>& contact_positions,
130 const std::vector<Eigen::Matrix3d>& contact_rotations) {
131 contact_status_.setContactPlacements(contact_positions, contact_rotations);
132}
133
134
136 const aligned_vector<SE3>& contact_placements) {
137 contact_status_.setContactPlacements(contact_placements);
138}
139
140
142 const int contact_index) const {
143 return contact_status_.contactPlacement(contact_index);
144}
145
146
147inline const Eigen::Vector3d& ImpactStatus::contactPosition(
148 const int contact_index) const {
149 return contact_status_.contactPosition(contact_index);
150}
151
152
153inline const Eigen::Matrix3d& ImpactStatus::contactRotation(
154 const int contact_index) const {
155 return contact_status_.contactRotation(contact_index);
156}
157
158
160 return contact_status_.contactPlacements();
161}
162
163
164inline const std::vector<Eigen::Vector3d>&
166 return contact_status_.contactPositions();
167}
168
169
170inline const std::vector<Eigen::Matrix3d>&
172 return contact_status_.contactRotations();
173}
174
175
176inline void ImpactStatus::setFrictionCoefficient(const int contact_index,
177 const double friction_coefficient) {
178 contact_status_.setFrictionCoefficient(contact_index, friction_coefficient);
179}
180
181
182inline void ImpactStatus::setFrictionCoefficient(const std::string& contact_frame_name,
183 const double friction_coefficient) {
184 contact_status_.setFrictionCoefficient(contact_frame_name, friction_coefficient);
185}
186
187
189 const std::vector<double>& friction_coefficients) {
190 contact_status_.setFrictionCoefficients(friction_coefficients);
191}
192
193
195 const std::unordered_map<std::string, double>& friction_coefficients) {
196 contact_status_.setFrictionCoefficients(friction_coefficients);
197}
198
199
200inline double ImpactStatus::frictionCoefficient(const int contact_index) const {
201 return contact_status_.frictionCoefficient(contact_index);
202}
203
204
206 const std::string& contact_frame_name) const {
207 return contact_status_.frictionCoefficient(contact_frame_name);
208}
209
210
211inline const std::vector<double>& ImpactStatus::frictionCoefficients() const {
212 return contact_status_.frictionCoefficients();
213}
214
215
217 contact_status_.setRandom();
218}
219
220} // namespace robotoc
221
222#endif // ROBOTOC_IMPACT_STATUS_HXX_
const std::vector< Eigen::Matrix3d > & contactRotations() const
Gets the contact rotations.
Definition: contact_status.hxx:386
void deactivateContacts(const std::vector< int > &contact_indices)
Deactivates contacts.
Definition: contact_status.hxx:203
const aligned_vector< SE3 > & contactPlacements() const
Gets the contact placements.
Definition: contact_status.hxx:374
const Eigen::Matrix3d & contactRotation(const int contact_index) const
Gets the contact rotation.
Definition: contact_status.hxx:360
double frictionCoefficient(const int contact_index) const
Gets the friction coefficint. Default value is 0.7.
Definition: contact_status.hxx:426
bool isContactActive(const int contact_index) const
Returns true if a contact is active and false if not.
Definition: contact_status.hxx:101
ContactType contactType(const int contact_index) const
Returns the type of the contact.
Definition: contact_status.hxx:73
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
void setRandom()
Fills contact status randomly.
Definition: contact_status.hxx:458
void deactivateContact(const int contact_index)
Deactivates a contact.
Definition: contact_status.hxx:160
void activateContacts(const std::vector< int > &contact_indices)
Activates contacts.
Definition: contact_status.hxx:185
void setFrictionCoefficient(const int contact_index, const double friction_coefficient)
Gets the friction coefficint.
Definition: contact_status.hxx:391
void setContactPlacement(const int contact_index, const Eigen::Vector3d &contact_position)
Sets a contact placement, that is, the position and rotation of the contact. The contact rotation is ...
Definition: contact_status.hxx:221
const std::vector< double > & frictionCoefficients() const
Gets the friction coefficints. Default value is 0.7.
Definition: contact_status.hxx:439
void setContactPlacements(const std::vector< Eigen::Vector3d > &contact_positions)
Sets contact placements. The rotation of each contact is set to Eigen::Matrix3d::Identity(),...
Definition: contact_status.hxx:272
const SE3 & contactPlacement(const int contact_index) const
Gets the contact placement.
Definition: contact_status.hxx:332
void setFrictionCoefficients(const std::vector< double > &friction_coefficients)
Sets the friction coefficints.
Definition: contact_status.hxx:408
const Eigen::Vector3d & contactPosition(const int contact_index) const
Gets the contact position.
Definition: contact_status.hxx:346
const std::vector< Eigen::Vector3d > & contactPositions() const
Gets the contact positions.
Definition: contact_status.hxx:380
bool hasActiveContacts() const
Returns true if there are active contacts and false if not.
Definition: contact_status.hxx:120
void activateContact(const int contact_index)
Activates a contact.
Definition: contact_status.hxx:135
const std::vector< ContactType > & contactTypes() const
Returns the types of the contacts.
Definition: contact_status.hxx:80
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
const std::vector< Eigen::Matrix3d > & contactRotations() const
Gets the contact rotations.
Definition: impact_status.hxx:171
void setContactPlacement(const int contact_index, const Eigen::Vector3d &contact_position)
Sets a contact placement, that is, the position and rotation of the contact. The contact rotation is ...
Definition: impact_status.hxx:102
bool operator!=(const ImpactStatus &other) const
Defines a comparison operator.
Definition: impact_status.hxx:40
ImpactStatus()
Default constructor.
Definition: impact_status.hxx:21
ContactType contactType(const int contact_index) const
Returns the type of the contact.
Definition: impact_status.hxx:45
void setFrictionCoefficients(const std::vector< double > &friction_coefficients)
Sets the friction coefficints.
Definition: impact_status.hxx:188
void setContactPlacements(const std::vector< Eigen::Vector3d > &contact_positions)
Sets contact placements. The rotation of each contact is set to Eigen::Matrix3d::Identity(),...
Definition: impact_status.hxx:122
int dimf() const
Returns the dimension of the active impact forces.
Definition: impact_status.hxx:70
const SE3 & contactPlacement(const int contact_index) const
Gets the contact placement.
Definition: impact_status.hxx:141
const std::vector< double > & frictionCoefficients() const
Gets the friction coefficints. Default value is 0.7.
Definition: impact_status.hxx:211
void setFrictionCoefficient(const int contact_index, const double friction_coefficient)
Gets the friction coefficint.
Definition: impact_status.hxx:176
void deactivateImpact(const int contact_index)
Deactivates a impact.
Definition: impact_status.hxx:85
double frictionCoefficient(const int contact_index) const
Gets the friction coefficint. Default value is 0.7.
Definition: impact_status.hxx:200
const std::vector< Eigen::Vector3d > & contactPositions() const
Gets the contact positions.
Definition: impact_status.hxx:165
const std::vector< bool > & isImpactActive() const
Returns the activity of the impacts.
Definition: impact_status.hxx:60
const std::vector< ContactType > & contactTypes() const
Returns the types of the contacts.
Definition: impact_status.hxx:50
const Eigen::Matrix3d & contactRotation(const int contact_index) const
Gets the contact rotation.
Definition: impact_status.hxx:153
const aligned_vector< SE3 > & contactPlacements() const
Gets the contact placements.
Definition: impact_status.hxx:159
int maxNumContacts() const
Returns the maximum number of the contacts.
Definition: impact_status.hxx:75
void setRandom()
Fills impact status randomly.
Definition: impact_status.hxx:216
bool hasActiveImpact() const
Returns true if there are active impacts and false if not.
Definition: impact_status.hxx:65
void activateImpact(const int contact_index)
Activates a impact.
Definition: impact_status.hxx:80
void activateImpacts(const std::vector< int > &impact_indices)
Activates impacts.
Definition: impact_status.hxx:90
void deactivateImpacts(const std::vector< int > &impact_indices)
Deactivates impacts.
Definition: impact_status.hxx:96
bool operator==(const ImpactStatus &other) const
Defines a comparison operator.
Definition: impact_status.hxx:26
bool isImpactActive(const int contact_index) const
Returns true if a contact is active and false if not.
Definition: impact_status.hxx:55
const Eigen::Vector3d & contactPosition(const int contact_index) const
Gets the contact position.
Definition: impact_status.hxx:147
Definition: constraint_component_base.hpp:17
ContactType
Types of contacts.
Definition: contact_status.hpp:22
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
std vector with Eigen::aligned_allocator.
Definition: aligned_vector.hpp:14
pinocchio::SE3 SE3
Using pinocchio::SE3 without its namespace.
Definition: se3.hpp:15