Commit 6140805e authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

ContactPhase: add a ContactModel member and remove friction coefficient

parent e5720363
......@@ -3,6 +3,7 @@
#define __multicontact_api_scenario_contact_patch_hpp__
#include "multicontact-api/scenario/fwd.hpp"
#include "multicontact-api/scenario/contact-model.hpp"
#include <pinocchio/spatial/se3.hpp>
#include "multicontact-api/serialization/archive.hpp"
#include "multicontact-api/serialization/spatial.hpp"
......@@ -15,29 +16,30 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
typedef _Scalar Scalar;
typedef ContactModelTpl<_Scalar> ContactModel;
typedef pinocchio::SE3Tpl<Scalar, 0> SE3;
/// \brief Default constructor.
ContactPatchTpl() : m_placement(SE3::Identity()), m_mu(-1.) {}
ContactPatchTpl() : m_placement(SE3::Identity()), m_contact_model() {}
/// \brief Init contact patch from a given placement.
explicit ContactPatchTpl(const SE3& placement) : m_placement(placement), m_mu(-1.) {}
explicit ContactPatchTpl(const SE3& placement) : m_placement(placement), m_contact_model() {}
/// \brief Init contact patch from a given placement and a friction coefficient
ContactPatchTpl(const SE3& placement, const Scalar mu) : m_placement(placement), m_mu(mu) {}
ContactPatchTpl(const SE3& placement, const Scalar mu) : m_placement(placement), m_contact_model(mu) {}
/// \brief Copy constructor
ContactPatchTpl(const ContactPatchTpl& other) : m_placement(other.m_placement), m_mu(other.m_mu) {}
ContactPatchTpl(const ContactPatchTpl& other) : m_placement(other.m_placement), m_contact_model(other.m_contact_model) {}
const SE3& placement() const { return m_placement; }
SE3& placement() { return m_placement; }
const Scalar& friction() const { return m_mu; }
Scalar& friction() { return m_mu; }
const Scalar& friction() const { return m_contact_model.m_mu; }
Scalar& friction() { return m_contact_model.m_mu; }
template <typename S2>
bool operator==(const ContactPatchTpl<S2>& other) const {
return m_placement == other.m_placement && m_mu == other.m_mu;
return m_placement == other.m_placement && m_contact_model == other.m_contact_model;
}
template <typename S2>
......@@ -46,7 +48,7 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
}
void disp(std::ostream& os) const {
os << "Placement:\n" << m_placement << std::endl << "Friction coefficient : " << m_mu << std::endl;
os << "Placement:\n" << m_placement << std::endl << "ContactModel : " << m_contact_model << std::endl;
}
template <typename S2>
......@@ -59,7 +61,7 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
/// \brief Placement of the contact patch
SE3 m_placement;
/// \brief friction coefficient for this contact
Scalar m_mu;
ContactModel m_contact_model;
private:
// Serialization of the class
......@@ -68,13 +70,13 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
template <class Archive>
void save(Archive& ar, const unsigned int /*version*/) const {
ar& boost::serialization::make_nvp("placement", m_placement);
ar& boost::serialization::make_nvp("mu", m_mu);
ar& boost::serialization::make_nvp("contact_model", m_contact_model);
}
template <class Archive>
void load(Archive& ar, const unsigned int /*version*/) {
ar >> boost::serialization::make_nvp("placement", m_placement);
ar >> boost::serialization::make_nvp("mu", m_mu);
ar >> boost::serialization::make_nvp("contact_model", m_contact_model);
}
BOOST_SERIALIZATION_SPLIT_MEMBER() // why is it required ? using only serialize() lead to compilation error,
......
......@@ -362,13 +362,10 @@ BOOST_AUTO_TEST_CASE(contact_model) {
mp3.m_contact_type = ContactType::POINT;
BOOST_CHECK(mp1 != mp3);
std::cout<<"ContactModel before serialization : \n "<<mp1<<std::endl;
std::string fileName("fileTest_contactModel");
mp1.saveAsText(fileName + ".txt");
ContactModel mp_from_text;
mp_from_text.loadFromText(fileName + ".txt");
std::cout<<"ContactModel after serialization : \n "<<mp_from_text<<std::endl;
BOOST_CHECK(mp1 == mp_from_text);
mp1.saveAsXML(fileName + ".xml", "ContactModel");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment