Verified Commit 91d0bda3 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

multibody/joint-generic: fix comparison operators

parent 2aeb6770
//
// Copyright (c) 2016-2020 CNRS INRIA
// Copyright (c) 2016-2021 CNRS INRIA
//
#ifndef __pinocchio_joint_generic_hpp__
......@@ -128,10 +128,20 @@ namespace pinocchio
static std::string classname() { return "JointData"; }
std::string shortname() const { return ::pinocchio::shortname(*this); }
template<typename JointDataDerived>
bool isEqual(const JointDataBase<JointDataDerived> & other) const
{
return ::pinocchio::isEqual(other.derived());
}
bool isEqual(const JointDataTpl & other) const
{
return Base::isEqual(other)
&& toVariant() == other.toVariant();
return Base::isEqual(other) && toVariant() == other.toVariant();
}
bool operator==(const JointDataTpl & other) const
{
return isEqual(other);
}
};
......@@ -191,11 +201,26 @@ namespace pinocchio
JointDataDerived createData() const
{ return ::pinocchio::createData<Scalar,Options,JointCollectionTpl>(*this); }
using Base::isEqual;
template<typename JointModelDerived>
bool isEqual(const JointModelBase<JointModelDerived> & other) const
{
return Base::hasSameIndexes(other.derived())
&& ::pinocchio::isEqual(*this,other.derived());;
}
bool isEqual(const JointModelTpl & other) const
{
return Base::isEqual(other)
&& toVariant() == other.toVariant();
return Base::isEqual(other) && toVariant() == other.toVariant();
}
bool operator==(const JointModelTpl & other) const
{
return isEqual(other);
}
bool operator!=(const JointModelTpl & other) const
{
return !(*this == other);
}
template<typename ConfigVector>
......@@ -225,7 +250,9 @@ namespace pinocchio
JointIndex id_impl() const { return ::pinocchio::id(*this); }
void setIndexes(JointIndex id, int nq, int nv)
{ ::pinocchio::setIndexes(*this,id, nq, nv); }
{
::pinocchio::setIndexes(*this, id, nq, nv);
}
/// \returns An expression of *this with the Scalar type casted to NewScalar.
template<typename NewScalar>
......@@ -238,6 +265,28 @@ namespace pinocchio
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
template<typename Scalar, int Options = 0, template<typename S, int O> class JointCollectionTpl, typename JointDataDerived>
bool operator==(const JointDataBase<JointDataDerived> & joint_data,
const JointDataTpl<Scalar,Options,JointCollectionTpl> & joint_data_generic)
{
return joint_data_generic == joint_data.derived();
}
template<typename Scalar, int Options = 0, template<typename S, int O> class JointCollectionTpl, typename JointModelDerived>
bool operator==(const JointModelBase<JointModelDerived> & joint_model,
const JointModelTpl<Scalar,Options,JointCollectionTpl> & joint_model_generic)
{
return joint_model_generic == joint_model.derived();
}
template<typename Scalar, int Options = 0, template<typename S, int O> class JointCollectionTpl, typename JointModelDerived>
bool operator!=(const JointModelBase<JointModelDerived> & joint_model,
const JointModelTpl<Scalar,Options,JointCollectionTpl> & joint_model_generic)
{
return joint_model_generic != joint_model.derived();
}
} // namespace pinocchio
#endif // ifndef __pinocchio_joint_generic_hpp__
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