5 #include "pinocchio/multibody/joint/joint-generic.hpp" 6 #include "pinocchio/multibody/liegroup/liegroup.hpp" 8 #include <boost/test/unit_test.hpp> 9 #include <boost/utility/binary.hpp> 13 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
25 JointData jdata = jmodel.createData();
27 const double scaling_factor = 2.;
28 ConstraintType constraint_ref(jdata.
S), constraint_ref_shared(jdata.
S);
29 ScaledConstraintType scaled_constraint(constraint_ref_shared,scaling_factor);
31 BOOST_CHECK(constraint_ref.nv() == scaled_constraint.nv());
33 typedef typename JointModel::TangentVector_t TangentVector_t;
34 TangentVector_t
v = TangentVector_t::Random();
37 Motion m_ref = scaling_factor * (
Motion)(constraint_ref * v);
43 typename ScaledConstraintType::DenseBase S = M.
act(scaled_constraint);
44 typename ScaledConstraintType::DenseBase S_ref = scaling_factor * M.
act(constraint_ref);
46 BOOST_CHECK(S.isApprox(S_ref));
50 typename ScaledConstraintType::DenseBase S = scaled_constraint.matrix();
51 typename ScaledConstraintType::DenseBase S_ref = scaling_factor * constraint_ref.matrix();
53 BOOST_CHECK(S.isApprox(S_ref));
58 typename ScaledConstraintType::DenseBase S = v.
cross(scaled_constraint);
59 typename ScaledConstraintType::DenseBase S_ref = scaling_factor * v.
cross(constraint_ref);
61 BOOST_CHECK(S.isApprox(S_ref));
66 const Eigen::DenseIndex
dim = 20;
67 const Matrix6x Fin = Matrix6x::Random(6,dim);
68 Eigen::MatrixXd Fout = scaled_constraint.transpose() * Fin;
69 Eigen::MatrixXd Fout_ref = scaling_factor * (constraint_ref.transpose() * Fin);
70 BOOST_CHECK(Fout.isApprox(Fout_ref));
73 Eigen::MatrixXd Stf = (scaled_constraint.transpose() * force_in);
74 Eigen::MatrixXd Stf_ref = scaling_factor * (constraint_ref.transpose() * force_in);
75 BOOST_CHECK(Stf_ref.isApprox(Stf));
81 Eigen::MatrixXd YS = Y * scaled_constraint;
82 Eigen::MatrixXd YS_ref = scaling_factor * (Y * constraint_ref);
84 BOOST_CHECK(YS.isApprox(YS_ref));
92 template <
typename Jo
intModel>
122 typedef boost::variant<
133 template<
typename Jo
intModel>
141 const double scaling_factor = 1.;
142 const double offset = 0.;
149 JointModelMimicType jmodel_mimic(jmodel.
derived(),scaling_factor,offset);
150 JointDataMimicType jdata_mimic = jmodel_mimic.createData();
152 BOOST_CHECK(jmodel_mimic.nq() == 0);
153 BOOST_CHECK(jmodel_mimic.nv() == 0);
155 BOOST_CHECK(jmodel_mimic.idx_q() == jmodel.
idx_q());
156 BOOST_CHECK(jmodel_mimic.idx_v() == jmodel.
idx_v());
158 BOOST_CHECK(jmodel_mimic.idx_q() == 0);
159 BOOST_CHECK(jmodel_mimic.idx_v() == 0);
161 typedef typename JointModelMimicType::ConfigVector_t ConfigVectorType;
163 ConfigVectorType
q0 = LieGroupType().randomConfiguration(-ConfigVectorType::Ones(),ConfigVectorType::Ones());
165 jmodel.
calc(jdata,q0);
166 jmodel_mimic.calc(jdata_mimic,q0);
168 BOOST_CHECK(((
SE3)jdata.
M).isApprox((
SE3)jdata_mimic.M()));
169 BOOST_CHECK(jdata.
S.matrix().isApprox(jdata_mimic.S.matrix()));
171 typedef typename JointModelMimicType::TangentVector_t TangentVectorType;
173 q0 = LieGroupType().randomConfiguration(-ConfigVectorType::Ones(),ConfigVectorType::Ones());
174 TangentVectorType
v0 = TangentVectorType::Random();
175 jmodel.
calc(jdata,q0,v0);
176 jmodel_mimic.calc(jdata_mimic,q0,v0);
178 BOOST_CHECK(((
SE3)jdata.
M).isApprox((
SE3)jdata_mimic.M()));
179 BOOST_CHECK(jdata.
S.matrix().isApprox(jdata_mimic.S.matrix()));
180 BOOST_CHECK(((
Motion)jdata.
v).isApprox((
Motion)jdata_mimic.v()));
186 template <
typename Jo
intModel>
216 typedef boost::variant<
229 typedef JointModelRX::ConfigVector_t ConfigVectorType;
230 double scaling = 1., offset = 0.;
232 ConfigVectorType
q0 = ConfigVectorType::Random();
235 BOOST_CHECK(q0 == q1);
239 BOOST_CHECK(q1 == ConfigVectorType::Constant(offset));
244 typedef JointModelRUBX::ConfigVector_t ConfigVectorType;
245 double scaling = 1., offset = 0.;
247 ConfigVectorType
q0 = ConfigVectorType::Random().normalized();
250 BOOST_CHECK(q0.isApprox(q1));
254 BOOST_CHECK(q1 == ConfigVectorType(math::cos(offset),math::sin(offset)));
265 BOOST_CHECK(jmodel.
id() == jmodel_ref.
id());
266 BOOST_CHECK(jmodel.
idx_q() == jmodel_ref.
idx_q());
267 BOOST_CHECK(jmodel.
idx_v() == jmodel_ref.
idx_v());
270 jmodel_generic.setIndexes(1,-2,-2);
272 BOOST_CHECK(jmodel_generic.id() == jmodel_ref.
id());
274 BOOST_AUTO_TEST_SUITE_END()
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
JointModelPrismaticTpl< double, 0, 0 > JointModelPX
void test_constraint_mimic(const JointModelBase< JointModel > &jmodel)
void test_joint_mimic(const JointModelBase< JointModel > &jmodel)
void operator()(const JointModelBase< JointModelRevoluteUnaligned > &) const
void setIndexes(JointIndex id, int q, int v)
static InertiaTpl Random()
JointModelRevoluteUnboundedTpl< double, 0, 1 > JointModelRUBY
JointModelRevoluteUnalignedTpl< double > JointModelRevoluteUnaligned
JointDataTpl< double > JointData
JointModelPrismaticTpl< double, 0, 1 > JointModelPY
Transformation_t M() const
void operator()(const JointModelBase< JointModel > &) const
JointDataDerived createData() const
MotionAlgebraAction< OtherSpatialType, Derived >::ReturnType cross(const OtherSpatialType &d) const
void operator()(const JointModelBase< JointModel > &) const
JointModelRevoluteTpl< double, 0, 1 > JointModelRY
BOOST_AUTO_TEST_CASE(test_constraint)
void operator()(const JointModelBase< JointModelPrismaticUnaligned > &) const
void operator()(const JointModelBase< JointModelPrismaticUnaligned > &) const
JointModelRevoluteTpl< double, 0, 2 > JointModelRZ
MotionTpl< double, 0 > Motion
void operator()(const JointModelBase< JointModelRevoluteUnaligned > &) const
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > & q1
Eigen::Matrix< double, 6, Eigen::Dynamic > Matrix6x
JointModelDerived & derived()
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs) const
void setIndexes(JointIndex id, int nq, int nv)
Main pinocchio namespace.
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > & q0
JointModelPrismaticTpl< double, 0, 2 > JointModelPZ
Common traits structure to fully define base classes for CRTP.
bool isApprox(const MotionDense< M2 > &m2, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
SE3GroupAction< D >::ReturnType act(const D &d) const
ay = aXb.act(by)
static MotionTpl Random()
JointModelRevoluteUnboundedTpl< double, 0, 0 > JointModelRUBX
JointModelPrismaticUnalignedTpl< double > JointModelPrismaticUnaligned
JointModelRevoluteTpl< double, 0, 0 > JointModelRX