5 #include "pinocchio/multibody/joint/joint-composite.hpp" 6 #include "pinocchio/algorithm/joint-configuration.hpp" 7 #include "pinocchio/algorithm/kinematics.hpp" 9 #include <boost/test/unit_test.hpp> 10 #include <boost/utility/binary.hpp> 13 using namespace Eigen;
15 template<
typename Jo
intModel>
18 template<
typename Jo
intModel>
25 template<
typename Jo
intModel>
35 typedef typename JointModel::ConfigVector_t ConfigVector_t;
36 typedef typename JointModel::TangentVector_t TangentVector_t;
39 typedef Eigen::Matrix<typename ConfigVector_t::Scalar, Eigen::Dynamic, 1, ConfigVector_t::Options> DynConfigVectorType;
40 typedef DynConfigVectorType DynTangentVectorType;
42 ConfigVector_t ql(ConfigVector_t::Constant(jmodel.
nq(),-M_PI));
43 ConfigVector_t qu(ConfigVector_t::Constant(jmodel.
nq(),M_PI));
44 DynConfigVectorType
q = LieGroupType().randomConfiguration(ql,qu);
46 BOOST_CHECK(jmodel.
nv() == jmodel_composite.
nv());
47 BOOST_CHECK(jmodel.
nq() == jmodel_composite.
nq());
50 jmodel_composite.
calc(jdata_composite,q);
52 BOOST_CHECK(jdata_composite.
M.isApprox((
SE3)jdata.
M));
53 BOOST_CHECK(jdata_composite.
S.matrix().isApprox(jdata.
S.matrix()));
55 q = LieGroupType().randomConfiguration(ql,qu);
56 DynTangentVectorType
v = TangentVector_t::Random(jmodel.
nv());
57 jmodel.
calc(jdata,q,v);
58 jmodel_composite.
calc(jdata_composite,q,v);
60 BOOST_CHECK(jdata_composite.
M.isApprox((
SE3)jdata.
M));
61 BOOST_CHECK(jdata_composite.
S.matrix().isApprox(jdata.
S.matrix()));
62 BOOST_CHECK(jdata_composite.
v.isApprox((
Motion)jdata.
v));
63 BOOST_CHECK(jdata_composite.
c.isApprox((
Motion)jdata.
c));
87 Inertia::Matrix6 I1 = I0;
88 Inertia::Matrix6 I2 = I0;
91 jmodel_composite.
calc_aba(jdata_composite,I2,
true);
95 BOOST_CHECK(jdata.
U.isApprox(jdata_composite.
U,prec));
96 BOOST_CHECK(jdata.
Dinv.isApprox(jdata_composite.
Dinv,prec));
97 BOOST_CHECK(jdata.
UDinv.isApprox(jdata_composite.
UDinv,prec));
103 if(jmodel.
shortname() ==
"JointModelFreeFlyer")
104 BOOST_CHECK((I1-I2).lpNorm<Eigen::Infinity>() < prec);
106 BOOST_CHECK(I1.isApprox(I2,prec));
112 jmodel_composite2.calc(jdata_composite2,q,v);
114 Inertia::Matrix6 I3 = I0;
115 jmodel_composite2.calc_aba(jdata_composite2,I3,
true);
117 if(jmodel.
shortname() ==
"JointModelFreeFlyer")
118 BOOST_CHECK((I3-I2).lpNorm<Eigen::Infinity>() < prec);
120 BOOST_CHECK(I3.isApprox(I2,prec));
122 BOOST_CHECK(jmodel_composite2 == jmodel_composite);
124 BOOST_CHECK(jdata_composite2.
U.isApprox(jdata_composite.
U,prec));
125 BOOST_CHECK(jdata_composite2.
Dinv.isApprox(jdata_composite.
Dinv,prec));
126 BOOST_CHECK(jdata_composite2.
UDinv.isApprox(jdata_composite.
UDinv,prec));
129 std::cout <<
"JointModelComposite operator<<:\n" << jmodel_composite << std::endl;
150 template <
typename Jo
intModel>
187 BOOST_AUTO_TEST_SUITE ( BOOST_TEST_MODULE )
208 BOOST_CHECK_MESSAGE( jmodel_composite.
nq() == 3,
"Chain did not work");
209 BOOST_CHECK_MESSAGE( jmodel_composite.
nv() == 3,
"Chain did not work");
210 BOOST_CHECK_MESSAGE( jmodel_composite.
njoints == 3,
"Chain did not work");
246 jmodel_composite_recursive.
addJoint(jmodel_composite_two_rx);
260 VectorXd q1_dot(VectorXd::Random(3));
265 BOOST_CHECK_MESSAGE( model_copy.
nq() == jmodel_composite_planar.
nq(),
"Test Copy Composite, nq are differents");
266 BOOST_CHECK_MESSAGE( model_copy.
nv() == jmodel_composite_planar.
nv(),
"Test Copy Composite, nv are differents");
268 jmodel_composite_planar.
calc(jdata_composite_planar,q1, q1_dot);
269 model_copy.
calc(data_copy,q1, q1_dot);
281 for(
int i=0;
i<10;
i++)
294 Data data_c(model_c);
296 BOOST_CHECK(model.
nv == model_c.
nv);
297 BOOST_CHECK(model.
nq == model_c.
nq);
303 BOOST_CHECK(data.oMi.back().isApprox(data_c.oMi.back()));
305 q.setRandom(model.
nq);
310 BOOST_CHECK(data.oMi.back().isApprox(data_c.oMi.back()));
311 BOOST_CHECK(data.v.back().isApprox(data_c.v.back()));
313 q.setRandom(model.
nq);
314 v.setRandom(model.
nv);
319 BOOST_CHECK(data.oMi.back().isApprox(data_c.oMi.back()));
320 BOOST_CHECK(data.v.back().isApprox(data_c.v.back()));
321 BOOST_CHECK(data.a.back().isApprox(data_c.a.back()));
324 BOOST_AUTO_TEST_SUITE_END ()
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
JointModelPrismaticTpl< double, 0, 0 > JointModelPX
SizeDepType< NV >::template SegmentReturn< D >::ConstType jointVelocitySelector(const Eigen::MatrixBase< D > &a) const
void test_joint_methods(const JointModelBase< JointModel > &jmodel, JointModelComposite &jmodel_composite)
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs) const
void setIndexes(JointIndex id, int q, int v)
boost::python::object matrix()
void operator()(const JointModelBase< JointModel > &) const
JointDataDerived createData() const
SizeDepType< NQ >::template SegmentReturn< D >::ConstType jointConfigSelector(const Eigen::MatrixBase< D > &a) const
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
void operator()(const JointModelBase< JointModelRevoluteUnaligned > &) const
static InertiaTpl Random()
JointModelRevoluteUnboundedTpl< double, 0, 1 > JointModelRUBY
JointModelRevoluteUnalignedTpl< double > JointModelRevoluteUnaligned
JointDataTpl< double > JointData
JointModelPrismaticTpl< double, 0, 1 > JointModelPY
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I) const
SizeDepType< NQ >::template SegmentReturn< D >::ConstType jointConfigSelector(const Eigen::MatrixBase< D > &a) const
JointDataDerived createData() const
void forwardKinematics(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Update the joint placements according to the current joint configuration.
JointModelRevoluteTpl< double, 0, 1 > JointModelRY
JointModelSphericalZYXTpl< double > JointModelSphericalZYX
JointIndex addJoint(const JointIndex parent, const JointModel &joint_model, const SE3 &joint_placement, const std::string &joint_name)
Add a joint to the kinematic tree with infinite bounds.
JointModelRevoluteTpl< double, 0, 2 > JointModelRZ
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs) const
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > & q1
BOOST_AUTO_TEST_CASE(test_basic)
JointModelTranslationTpl< double > JointModelTranslation
Transformation_t M() const
void setIndexes(JointIndex id, int nq, int nv)
int njoints
Number of joints contained in the JointModelComposite.
Main pinocchio namespace.
JointModelSphericalTpl< double > JointModelSpherical
SizeDepType< NV >::template ColsReturn< D >::ConstType jointCols(const Eigen::MatrixBase< D > &A) const
int nv
Dimension of the velocity vector space.
JointModelPrismaticTpl< double, 0, 2 > JointModelPZ
JointModelFreeFlyerTpl< double > JointModelFreeFlyer
VectorXs ConfigVectorType
Dense vectorized version of a joint configuration vector.
SizeDepType< NV >::template ColsReturn< D >::ConstType jointCols(const Eigen::MatrixBase< D > &A) const
SizeDepType< NV >::template SegmentReturn< D >::ConstType jointVelocitySelector(const Eigen::MatrixBase< D > &a) const
JointModelRevoluteUnboundedTpl< double, 0, 0 > JointModelRUBX
JointModelPrismaticUnalignedTpl< double > JointModelPrismaticUnaligned
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorXd
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
JointModelRevoluteTpl< double, 0, 0 > JointModelRX
JointCollectionTpl & model
int nq
Dimension of the configuration vector representation.
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Type > &I, const bool update_I=false) const
JointModelPlanarTpl< double > JointModelPlanar
void operator()(const JointModelBase< JointModelPrismaticUnaligned > &) const
std::string shortname() const