contact-patch.hpp
Go to the documentation of this file.
1 
2 #ifndef __multicontact_api_scenario_contact_patch_hpp__
3 #define __multicontact_api_scenario_contact_patch_hpp__
4 
5 #include <pinocchio/spatial/se3.hpp>
6 
11 
12 namespace multicontact_api {
13 namespace scenario {
14 
15 template <typename _Scalar>
17  : public serialization::Serializable<ContactPatchTpl<_Scalar> > {
18  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
19 
20  typedef _Scalar Scalar;
22  typedef pinocchio::SE3Tpl<Scalar, 0> SE3;
23 
26 
28  explicit ContactPatchTpl(const SE3& placement)
30 
33  ContactPatchTpl(const SE3& placement, const Scalar mu)
35 
37  ContactPatchTpl(const SE3& placement, const ContactModel contact_model)
38  : m_contact_model(contact_model), m_placement(placement) {}
39 
43  m_placement(other.m_placement) {}
44 
45  const SE3& placement() const { return m_placement; }
46  SE3& placement() { return m_placement; }
47 
48  const Scalar& friction() const { return m_contact_model.m_mu; }
50 
51  template <typename S2>
52  bool operator==(const ContactPatchTpl<S2>& other) const {
53  return m_placement == other.m_placement &&
55  }
56 
57  template <typename S2>
58  bool operator!=(const ContactPatchTpl<S2>& other) const {
59  return !(*this == other);
60  }
61 
62  void disp(std::ostream& os) const {
63  os << "Placement:\n"
64  << m_placement << std::endl
65  << "ContactModel : " << m_contact_model << std::endl;
66  }
67 
68  template <typename S2>
69  friend std::ostream& operator<<(std::ostream& os,
70  const ContactPatchTpl<S2>& cp) {
71  cp.disp(os);
72  return os;
73  }
74 
77 
78  protected:
81 
82  private:
83  // Serialization of the class
85 
86  template <class Archive>
87  void save(Archive& ar, const unsigned int /*version*/) const {
88  ar& boost::serialization::make_nvp("placement", m_placement);
89  ar& boost::serialization::make_nvp("contact_model", m_contact_model);
90  }
91 
92  template <class Archive>
93  void load(Archive& ar, const unsigned int version) {
94  ar >> boost::serialization::make_nvp("placement", m_placement);
95  if (version >= 1) {
96  ar >> boost::serialization::make_nvp("contact_model", m_contact_model);
97  } else {
98  double mu;
99  ar >> boost::serialization::make_nvp("mu", mu);
101  }
102  }
103 
104  BOOST_SERIALIZATION_SPLIT_MEMBER() // why is it required ? using only
105  // serialize() lead to compilation error,
106  // probably because of the SE3
107 
108 }; // struct ContactPatchTpl
109 } // namespace scenario
110 } // namespace multicontact_api
111 
114 
115 #endif // __multicontact_api_scenario_contact_patch_hpp__
void load(Archive &ar, pinocchio::container::aligned_vector< T > &v, const unsigned int version)
Definition: aligned-vector.hpp:24
void save(Archive &ar, const pinocchio::container::aligned_vector< T > &v, const unsigned int version)
Definition: aligned-vector.hpp:16
Definition: ellipsoid.hpp:12
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition: archive.hpp:22
Definition: contact-model.hpp:21
Scalar m_mu
Friction coefficient.
Definition: contact-model.hpp:116
Definition: contact-patch.hpp:17
SE3 & placement()
Definition: contact-patch.hpp:46
void disp(std::ostream &os) const
Definition: contact-patch.hpp:62
bool operator==(const ContactPatchTpl< S2 > &other) const
Definition: contact-patch.hpp:52
SE3 m_placement
Placement of the contact patch.
Definition: contact-patch.hpp:80
friend std::ostream & operator<<(std::ostream &os, const ContactPatchTpl< S2 > &cp)
Definition: contact-patch.hpp:69
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Definition: contact-patch.hpp:20
ContactModelTpl< _Scalar > ContactModel
Definition: contact-patch.hpp:21
const Scalar & friction() const
Definition: contact-patch.hpp:48
ContactModel m_contact_model
Contact model of this contact.
Definition: contact-patch.hpp:76
pinocchio::SE3Tpl< Scalar, 0 > SE3
Definition: contact-patch.hpp:22
const SE3 & placement() const
Definition: contact-patch.hpp:45
ContactPatchTpl(const ContactPatchTpl &other)
Copy constructor.
Definition: contact-patch.hpp:41
ContactPatchTpl(const SE3 &placement)
Init contact patch from a given placement.
Definition: contact-patch.hpp:28
friend class boost::serialization::access
Definition: contact-patch.hpp:84
ContactPatchTpl(const SE3 &placement, const Scalar mu)
Init contact patch from a given placement and a friction coefficient.
Definition: contact-patch.hpp:33
ContactPatchTpl()
Default constructor.
Definition: contact-patch.hpp:25
ContactPatchTpl(const SE3 &placement, const ContactModel contact_model)
Init contact patch from a given placement and a contact model.
Definition: contact-patch.hpp:37
bool operator!=(const ContactPatchTpl< S2 > &other) const
Definition: contact-patch.hpp:58
Scalar & friction()
Definition: contact-patch.hpp:49