robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
contact_status.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_CONTACT_STATUS_HPP_
2#define ROBOTOC_CONTACT_STATUS_HPP_
3
4#include <vector>
5#include <string>
6#include <unordered_map>
7#include <iostream>
8
9#include "Eigen/Core"
10
11#include "robotoc/robot/se3.hpp"
14
15
16namespace robotoc {
17
22enum class ContactType {
25};
26
27
33public:
41 ContactStatus(const std::vector<ContactType>& contact_types,
42 const std::vector<std::string>& contact_frame_names,
43 const double default_friction_coefficient=0.7);
44
49
53 ~ContactStatus() = default;
54
58 ContactStatus(const ContactStatus&) = default;
59
64
68 ContactStatus(ContactStatus&&) noexcept = default;
69
73 ContactStatus& operator=(ContactStatus&&) noexcept = default;
74
78 bool operator==(const ContactStatus& other) const;
79
83 bool operator!=(const ContactStatus& other) const;
84
90 ContactType contactType(const int contact_index) const;
91
96 const std::vector<ContactType>& contactTypes() const;
97
103 const std::string& contactFrameName(const int contact_index) const;
104
109 const std::vector<std::string>& contactFrameNames() const;
110
116 bool isContactActive(const int contact_index) const;
117
123 bool isContactActive(const std::string& contact_frame_name) const;
124
129 const std::vector<bool>& isContactActive() const;
130
135 bool hasActiveContacts() const;
136
141 int dimf() const;
142
147 int maxNumContacts() const;
148
153 void activateContact(const int contact_index);
154
159 void activateContact(const std::string& contact_frame_name);
160
165 void deactivateContact(const int contact_index);
166
171 void deactivateContact(const std::string& contact_frame_name);
172
177 void activateContacts(const std::vector<int>& contact_indices);
178
183 void activateContacts(const std::vector<std::string>& contact_frame_names);
184
189 void deactivateContacts(const std::vector<int>& contact_indices);
190
195 void deactivateContacts(const std::vector<std::string>& contact_frame_names);
196
207 void setContactPlacement(const int contact_index,
208 const Eigen::Vector3d& contact_position);
209
220 void setContactPlacement(const std::string& contact_frame_name,
221 const Eigen::Vector3d& contact_position);
222
233 void setContactPlacement(const int contact_index,
234 const Eigen::Vector3d& contact_position,
235 const Eigen::Matrix3d& contact_rotation);
236
247 void setContactPlacement(const std::string& contact_frame_name,
248 const Eigen::Vector3d& contact_position,
249 const Eigen::Matrix3d& contact_rotation);
250
260 void setContactPlacement(const int contact_index,
261 const SE3& contact_placement);
262
272 void setContactPlacement(const std::string& contact_frame_name,
273 const SE3& contact_placement);
274
283 const std::vector<Eigen::Vector3d>& contact_positions);
284
293 const std::unordered_map<std::string, Eigen::Vector3d>& contact_positions);
294
303 const std::vector<Eigen::Vector3d>& contact_positions,
304 const std::vector<Eigen::Matrix3d>& contact_rotations);
305
314 const std::unordered_map<std::string, Eigen::Vector3d>& contact_positions,
315 const std::unordered_map<std::string, Eigen::Matrix3d>& contact_rotations);
316
322 void setContactPlacements(const aligned_vector<SE3>& contact_placements);
323
330 const aligned_unordered_map<std::string, SE3>& contact_placements);
331
337 const SE3& contactPlacement(const int contact_index) const;
338
344 const SE3& contactPlacement(const std::string& contact_frame_name) const;
345
351 const Eigen::Vector3d& contactPosition(const int contact_index) const;
352
358 const Eigen::Vector3d& contactPosition(
359 const std::string& contact_frame_name) const;
360
366 const Eigen::Matrix3d& contactRotation(const int contact_index) const;
367
373 const Eigen::Matrix3d& contactRotation(
374 const std::string& contact_frame_name) const;
375
380 const aligned_vector<SE3>& contactPlacements() const;
381
386 const std::vector<Eigen::Vector3d>& contactPositions() const;
387
392 const std::vector<Eigen::Matrix3d>& contactRotations() const;
393
399 void setFrictionCoefficient(const int contact_index,
400 const double friction_coefficient);
401
407 void setFrictionCoefficient(const std::string& contact_frame_name,
408 const double friction_coefficient);
409
415 void setFrictionCoefficients(const std::vector<double>& friction_coefficients);
416
423 const std::unordered_map<std::string, double>& friction_coefficients);
424
430 double frictionCoefficient(const int contact_index) const;
431
437 double frictionCoefficient(const std::string& contact_frame_name) const;
438
443 const std::vector<double>& frictionCoefficients() const;
444
450 int findContactIndex(const std::string& contact_frame_name) const;
451
455 void setRandom();
456
460 void disp(std::ostream& os) const;
461
462 friend std::ostream& operator<<(std::ostream& os,
463 const ContactStatus& contact_status);
464
465 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
466
467private:
468 std::vector<ContactType> contact_types_;
469 std::vector<std::string> contact_frame_names_;
470 std::vector<bool> is_contact_active_;
471 aligned_vector<SE3> contact_placements_;
472 std::vector<Eigen::Vector3d> contact_positions_;
473 std::vector<Eigen::Matrix3d> contact_rotations_;
474 std::vector<double> friction_coefficients_;
475 int dimf_, max_contacts_, max_num_contacts_;
476 bool has_active_contacts_;
477
478 void setHasActiveContacts();
479
480};
481
482} // namespace robotoc
483
484#include "robotoc/robot/contact_status.hxx"
485
486#endif // ROBOTOC_CONTACT_STATUS_HPP_
Contact status of robot model.
Definition: contact_status.hpp:32
const std::string & contactFrameName(const int contact_index) const
Returns the name of the contact frame.
Definition: contact_status.hxx:85
const std::vector< Eigen::Matrix3d > & contactRotations() const
Gets the contact rotations.
Definition: contact_status.hxx:386
ContactStatus()
Default constructor.
Definition: contact_status.hxx:39
int findContactIndex(const std::string &contact_frame_name) const
Finds the contact index correspoinding to the input contact frame name.
Definition: contact_status.hxx:444
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
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
ContactStatus(const ContactStatus &)=default
Default copy constructor.
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
const std::vector< bool > & isContactActive() const
Returns the activity of the contacts.
Definition: contact_status.hxx:115
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
ContactStatus(ContactStatus &&) noexcept=default
Default move constructor.
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
~ContactStatus()=default
Default destructor.
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
ContactStatus & operator=(const ContactStatus &)=default
Default copy assign operator.
void activateContact(const int contact_index)
Activates a contact.
Definition: contact_status.hxx:135
const std::vector< std::string > & contactFrameNames() const
Returns the names of the contact frames.
Definition: contact_status.hxx:96
void disp(std::ostream &os) const
Displays the contact status onto a ostream.
const std::vector< ContactType > & contactTypes() const
Returns the types of the contacts.
Definition: contact_status.hxx:80
Kinematics and dynamic model of a point contact.
Definition: point_contact.hpp:22
Kinematics and dynamic model of a surface contact.
Definition: surface_contact.hpp:22
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
std::unordered_map< Key, T, std::hash< Key >, std::equal_to< Key >, Eigen::aligned_allocator< std::pair< Key, T > > > aligned_unordered_map
std unordered_map with Eigen::aligned_allocator.
Definition: aligned_unordered_map.hpp:15
pinocchio::SE3 SE3
Using pinocchio::SE3 without its namespace.
Definition: se3.hpp:15