Commit 23c4ada3 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Format] run gepetto/linters

parent daf33796
......@@ -14,14 +14,12 @@
#include <curves/exact_cubic.h>
#include <curves/cubic_hermite_spline.h>
namespace multicontact_api {
namespace python {
void exposeContactPhase() {
ContactPhasePythonVisitor<multicontact_api::scenario::ContactPhase>::expose("ContactPhase");
}
}
} // namespace python
// namespace python
} // namespace multicontact_api
......@@ -14,7 +14,6 @@
#include <curves/exact_cubic.h>
#include <curves/cubic_hermite_spline.h>
namespace multicontact_api {
namespace python {
void exposeContactSequence() {
......
......@@ -19,8 +19,6 @@ void exposeEnumConicType() {
.value("CONIC_UNDEFINED", CONIC_UNDEFINED);
}
void exposeScenarioEnums() {
exposeEnumConicType();
}
void exposeScenarioEnums() { exposeEnumConicType(); }
} // namespace python
} // namespace multicontact_api
......@@ -22,15 +22,15 @@ struct ContactPatchPythonVisitor : public boost::python::def_visitor<ContactPatc
template <class PyClass>
void visit(PyClass& cl) const {
cl
.def(bp::init<>(bp::arg(""),"Default constructor."))
cl.def(bp::init<>(bp::arg(""), "Default constructor."))
.def(bp::init<SE3>(bp::arg("placement"), "Init with a given placement."))
.def(bp::init<SE3,Scalar>(bp::args("placement","friction"), "Init with a given placement and friction coefficient."))
.def(bp::init<SE3, Scalar>(bp::args("placement", "friction"),
"Init with a given placement and friction coefficient."))
.def(bp::init<ContactPatch>(bp::arg("other"), "Copy contructor."))
.add_property("placement",
// getter require to use "make_function" to pass the return_internal_reference policy (return ref to custom object)
bp::make_function(&getPlacement,bp::return_internal_reference<>()),
&setPlacement,
// getter require to use "make_function" to pass the return_internal_reference policy (return ref
// to custom object)
bp::make_function(&getPlacement, bp::return_internal_reference<>()), &setPlacement,
"Placement of the patch represented as a pinocchio SE3 object.")
.add_property("friction", &getFriction, &setFriction,
"Friction coefficient between the robot and the environment for this contact.")
......@@ -49,9 +49,9 @@ struct ContactPatchPythonVisitor : public boost::python::def_visitor<ContactPatc
protected:
// define setter and getter
static SE3& getPlacement(ContactPatch& self){return self.placement();}
static SE3& getPlacement(ContactPatch& self) { return self.placement(); }
static void setPlacement(ContactPatch& self, const SE3& placement) { self.placement() = placement; }
static Scalar getFriction(ContactPatch& self){return self.friction();}
static Scalar getFriction(ContactPatch& self) { return self.friction(); }
static void setFriction(ContactPatch& self, const Scalar& friction) { self.friction() = friction; }
static ContactPatch copy(const ContactPatch& self) { return ContactPatch(self); }
};
......
......@@ -20,25 +20,22 @@ template <typename CS>
struct ContactSequencePythonVisitor : public bp::def_visitor<ContactSequencePythonVisitor<CS> > {
typedef typename CS::ContactPhaseVector ContactPhaseVector;
template <class PyClass>
void visit(PyClass& cl) const {
cl.def(bp::init<size_t>(bp::arg("size"), "Default constructor from a given size."))
.def(bp::init<>(bp::arg(""),"Default constructor."))
.def(bp::init<>(bp::arg(""), "Default constructor."))
.def(bp::init<CS>(bp::args("other"), "Copy contructor."))
.def("size", &CS::size, "Return the size of the contact sequence.")
.def("resize", &CS::resize,bp::arg("size"), "Resize the vector of ContactPhases.")
.def("append",&CS::append,bp::arg("ContactPhase"),
"Add the given ContactPhase at the end of the sequence. \n"
"Return the new id of this ContactPhase inside the sequence.")
.add_property("contactPhases",
bp::make_getter(&CS::m_contact_phases,bp::return_internal_reference<>()),
"Vector of Contact Phases contained in the sequence")
.def("resize", &CS::resize, bp::arg("size"), "Resize the vector of ContactPhases.")
.def("append", &CS::append, bp::arg("ContactPhase"),
"Add the given ContactPhase at the end of the sequence. \n"
"Return the new id of this ContactPhase inside the sequence.")
.add_property("contactPhases", bp::make_getter(&CS::m_contact_phases, bp::return_internal_reference<>()),
"Vector of Contact Phases contained in the sequence")
.def(bp::self == bp::self)
.def(bp::self != bp::self)
.def("copy", &copy, "Returns a copy of *this.");
;
;
}
static void expose(const std::string& class_name) {
......@@ -47,15 +44,11 @@ struct ContactSequencePythonVisitor : public bp::def_visitor<ContactSequencePyth
.def(ContactSequencePythonVisitor<CS>())
.def(SerializableVisitor<CS>());
bp::class_<ContactPhaseVector>("ContactPhaseVector")
.def(bp::vector_indexing_suite<ContactPhaseVector>() );
bp::class_<ContactPhaseVector>("ContactPhaseVector").def(bp::vector_indexing_suite<ContactPhaseVector>());
}
protected:
static CS copy(const CS& self) { return CS(self); }
protected:
static CS copy(const CS& self) { return CS(self); }
};
} // namespace python
} // namespace multicontact_api
......
......@@ -19,7 +19,6 @@ inline void exposeScenario() {
exposeContactPatch();
exposeContactPhase();
exposeContactSequence();
}
} // namespace python
......
......@@ -17,37 +17,29 @@
#include <boost/serialization/base_object.hpp>
#include <curves/serialization/registeration.hpp>
template <typename Curve>
struct CurveMap : public std::map<std::string,Curve> {
typedef CurveMap<Curve> CurveMap_t;
typedef std::map<std::string,Curve> Parent;
struct CurveMap : public std::map<std::string, Curve> {
typedef CurveMap<Curve> CurveMap_t;
typedef std::map<std::string, Curve> Parent;
// define operator == for map of shared ptr: start by checking if the ptr are same, otherwise check if the values are the sames
// define operator == for map of shared ptr: start by checking if the ptr are same, otherwise check if the values are
// the sames
bool operator==(const CurveMap_t& other) const {
if(this->size() != other.size())
return false;
for(typename Parent::const_iterator it = this->begin() ; it != this->end() ; ++it){
if(other.count(it->first) < 1)
return false;
if((it->second != other.at(it->first)) && !(it->second->isApprox(other.at(it->first).get())))
return false;
if (this->size() != other.size()) return false;
for (typename Parent::const_iterator it = this->begin(); it != this->end(); ++it) {
if (other.count(it->first) < 1) return false;
if ((it->second != other.at(it->first)) && !(it->second->isApprox(other.at(it->first).get()))) return false;
}
return true;
}
bool operator!=(const CurveMap_t& other)const {
return !(*this == other);
}
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/) {
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Parent);
}
bool operator!=(const CurveMap_t& other) const { return !(*this == other); }
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/) {
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Parent);
}
};
#endif // CURVEMAP_HPP
#endif // CURVEMAP_HPP
......@@ -18,21 +18,16 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
typedef pinocchio::SE3Tpl<Scalar, 0> SE3;
/// \brief Default constructor.
ContactPatchTpl()
: m_placement(SE3::Identity()), m_mu(-1.) {}
ContactPatchTpl() : m_placement(SE3::Identity()), m_mu(-1.) {}
/// \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_mu(-1.) {}
/// \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_mu(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_mu(other.m_mu) {}
const SE3& placement() const { return m_placement; }
SE3& placement() { return m_placement; }
......@@ -40,7 +35,6 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
const Scalar& friction() const { return m_mu; }
Scalar& friction() { return m_mu; }
template <typename S2>
bool operator==(const ContactPatchTpl<S2>& other) const {
return m_placement == other.m_placement && m_mu == other.m_mu;
......@@ -51,11 +45,8 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
return !(*this == other);
}
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 << "Friction coefficient : " << m_mu << std::endl;
}
template <typename S2>
......@@ -64,35 +55,33 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
return os;
}
protected:
/// \brief Placement of the contact patch
SE3 m_placement;
/// \brief friction coefficient for this contact
Scalar m_mu;
protected:
/// \brief Placement of the contact patch
SE3 m_placement;
/// \brief friction coefficient for this contact
Scalar m_mu;
private:
// Serialization of the class
friend class boost::serialization::access;
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);
}
private:
// Serialization of the class
friend class boost::serialization::access;
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);
}
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);
}
BOOST_SERIALIZATION_SPLIT_MEMBER() // why is it required ? using only serialize() lead to compilation error, probably because of the SE3
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);
}
}; // struct ContactPatchTpl
}//scenario
}//multicontact_api
BOOST_SERIALIZATION_SPLIT_MEMBER() // why is it required ? using only serialize() lead to compilation error,
// probably because of the SE3
}; // struct ContactPatchTpl
} // namespace scenario
} // namespace multicontact_api
#endif // __multicontact_api_scenario_contact_patch_hpp__
#endif // __multicontact_api_scenario_contact_patch_hpp__
#ifndef __multicontact_api_scenario_contact_sequence_hpp__
#define __multicontact_api_scenario_contact_sequence_hpp__
#include "multicontact-api/scenario/fwd.hpp"
#include "multicontact-api/scenario/contact-phase.hpp"
#include "multicontact-api/serialization/archive.hpp"
#include <vector>
#include <boost/serialization/vector.hpp>
namespace multicontact_api {
namespace scenario {
namespace multicontact_api{
namespace scenario {
template<class _ContactPhase>
struct ContactSequenceTpl : public serialization::Serializable< ContactSequenceTpl<_ContactPhase> >
{
template <class _ContactPhase>
struct ContactSequenceTpl : public serialization::Serializable<ContactSequenceTpl<_ContactPhase> > {
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
typedef _ContactPhase ContactPhase;
typedef typename ContactPhase::Scalar Scalar;
typedef std::vector<ContactPhase> ContactPhaseVector;
ContactSequenceTpl(const size_t size = 0)
: m_contact_phases(size)
{}
/// \brief Copy contructor
ContactSequenceTpl(const ContactSequenceTpl & other)
: m_contact_phases(other.m_contact_phases)
{}
size_t size() const { return m_contact_phases.size(); }
bool operator==(const ContactSequenceTpl & other) const
{
return
m_contact_phases == other.m_contact_phases
;
}
bool operator!=(const ContactSequenceTpl & other) const
{ return !(*this == other); }
void resize(const size_t size)
{
m_contact_phases.resize(size);
}
/* Accessors to the contact Phases */
/**
* @brief append Add the given Phase at the end of the sequence
* @param contactPhase the phase to end
* @return The id of the phase added in the sequence
*/
size_t append(const ContactPhase& contactPhase){
m_contact_phases.push_back(contactPhase);
return m_contact_phases.size()-1;
}
/**
* @brief contactPhases return a Const copy of the contact phase vector in this sequence.
* Prefer accessing the contact phases through the contactPhase(id) as this one create a copy
* @return a Const copy of the contact phase vector in this sequence
*/
const ContactPhaseVector contactPhases() const{
return m_contact_phases;
}
/**
* @brief contactPhase return a reference to the contactPhase stored at the given Id
* @param id the desired Id in the contact sequence
* @return a reference to the ContactPhase
*/
ContactPhase& contactPhase(const size_t id){
if(id >= m_contact_phases.size())
//throw std::invalid_argument("Contact Sequence size is "+m_contact_phases.size()+" given Id is "+id);
throw std::invalid_argument("Given Id is greater than the vector size");
return m_contact_phases.at(id);
ContactSequenceTpl(const size_t size = 0) : m_contact_phases(size) {}
/// \brief Copy contructor
ContactSequenceTpl(const ContactSequenceTpl& other) : m_contact_phases(other.m_contact_phases) {}
size_t size() const { return m_contact_phases.size(); }
bool operator==(const ContactSequenceTpl& other) const { return m_contact_phases == other.m_contact_phases; }
bool operator!=(const ContactSequenceTpl& other) const { return !(*this == other); }
void resize(const size_t size) { m_contact_phases.resize(size); }
/* Accessors to the contact Phases */
/**
* @brief append Add the given Phase at the end of the sequence
* @param contactPhase the phase to end
* @return The id of the phase added in the sequence
*/
size_t append(const ContactPhase& contactPhase) {
m_contact_phases.push_back(contactPhase);
return m_contact_phases.size() - 1;
}
/**
* @brief contactPhases return a Const copy of the contact phase vector in this sequence.
* Prefer accessing the contact phases through the contactPhase(id) as this one create a copy
* @return a Const copy of the contact phase vector in this sequence
*/
const ContactPhaseVector contactPhases() const { return m_contact_phases; }
/**
* @brief contactPhase return a reference to the contactPhase stored at the given Id
* @param id the desired Id in the contact sequence
* @return a reference to the ContactPhase
*/
ContactPhase& contactPhase(const size_t id) {
if (id >= m_contact_phases.size())
// throw std::invalid_argument("Contact Sequence size is "+m_contact_phases.size()+" given Id is "+id);
throw std::invalid_argument("Given Id is greater than the vector size");
return m_contact_phases.at(id);
}
/**
* @brief removePhase remove the given contactPhase from the sequence
* @param id the Id of the phase to remove
*/
void removePhase(const size_t id) {
if (id >= m_contact_phases.size()) throw std::invalid_argument("Given Id is greater than the vector size");
m_contact_phases.erase(m_contact_phases.begin() + id);
}
/* End Accessors to the contact Phases */
/* Helpers */
/* End Helpers */
/*Public Attributes*/
ContactPhaseVector m_contact_phases;
/*Public Attributes*/
private:
// Serialization of the class
friend class boost::serialization::access;
template <class Archive>
void save(Archive& ar, const unsigned int /*version*/) const {
const size_t m_size = size();
ar& boost::serialization::make_nvp("size", m_size);
for (typename ContactPhaseVector::const_iterator it = m_contact_phases.begin(); it != m_contact_phases.end();
++it) {
ar& boost::serialization::make_nvp("contact_phase", *it);
}
/**
* @brief removePhase remove the given contactPhase from the sequence
* @param id the Id of the phase to remove
*/
void removePhase(const size_t id){
if(id >= m_contact_phases.size())
throw std::invalid_argument("Given Id is greater than the vector size");
m_contact_phases.erase(m_contact_phases.begin() + id);
}
/* End Accessors to the contact Phases */
/* Helpers */
/* End Helpers */
/*Public Attributes*/
ContactPhaseVector m_contact_phases;
/*Public Attributes*/
private:
// Serialization of the class
friend class boost::serialization::access;
template<class Archive>
void save(Archive & ar, const unsigned int /*version*/) const
{
const size_t m_size = size();
ar & boost::serialization::make_nvp("size",m_size);
for(typename ContactPhaseVector::const_iterator it = m_contact_phases.begin();
it != m_contact_phases.end(); ++it)
{
ar & boost::serialization::make_nvp("contact_phase",*it);
}
}
template<class Archive>
void load(Archive & ar, const unsigned int /*version*/)
{
size_t m_size;
ar >> boost::serialization::make_nvp("size",m_size);
assert(m_size>0);
resize(m_size);
for(typename ContactPhaseVector::iterator it = m_contact_phases.begin();
it != m_contact_phases.end(); ++it)
{
ar >> boost::serialization::make_nvp("contact_phase",*it);
}
}
template <class Archive>
void load(Archive& ar, const unsigned int /*version*/) {
size_t m_size;
ar >> boost::serialization::make_nvp("size", m_size);
assert(m_size > 0);
resize(m_size);
for (typename ContactPhaseVector::iterator it = m_contact_phases.begin(); it != m_contact_phases.end(); ++it) {
ar >> boost::serialization::make_nvp("contact_phase", *it);
}
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
BOOST_SERIALIZATION_SPLIT_MEMBER()
}; // end class ContactSequence
}; // end class ContactSequence
}//namespace scenario
} // namespace multicontact
#endif // __multicontact_api_scenario_contact_sequence_hpp__
} // namespace scenario
} // namespace multicontact_api
#endif // __multicontact_api_scenario_contact_sequence_hpp__
......@@ -7,26 +7,31 @@
#include "multicontact-api/geometry/fwd.hpp"
#include <pinocchio/spatial/fwd.hpp>
namespace multicontact_api{
namespace scenario{
namespace multicontact_api {
namespace scenario {
template<class T> struct traits {};
template <class T>
struct traits {};
template<typename _Scalar> struct ContactPatchTpl;
typedef ContactPatchTpl<double> ContactPatch;
template <typename _Scalar>
struct ContactPatchTpl;
typedef ContactPatchTpl<double> ContactPatch;
template<typename _Scalar> struct ContactPhaseTpl;
typedef ContactPhaseTpl<double> ContactPhase;
template <typename _Scalar>
struct ContactPhaseTpl;
typedef ContactPhaseTpl<double> ContactPhase;
template<typename _ContactPhase> struct ContactSequenceTpl;
typedef ContactSequenceTpl<ContactPhase> ContactSequence;
template <typename _ContactPhase>
struct ContactSequenceTpl;
typedef ContactSequenceTpl<ContactPhase> ContactSequence;
template<typename Scalar> struct ContactModelPlanarTpl;
typedef ContactModelPlanarTpl<double> ContactModelPlanar;
template <typename Scalar>
struct ContactModelPlanarTpl;
typedef ContactModelPlanarTpl<double> ContactModelPlanar;
enum ConicType { CONIC_SOWC, CONIC_DOUBLE_DESCRIPTION, CONIC_UNDEFINED };
enum ConicType { CONIC_SOWC, CONIC_DOUBLE_DESCRIPTION, CONIC_UNDEFINED };
}
}
} // namespace scenario
} // namespace multicontact_api
#endif // ifndef __multicontact_api_scenario_fwd_hpp__
#endif // ifndef __multicontact_api_scenario_fwd_hpp__