Go to the documentation of this file.
17 #include <boost/test/unit_test.hpp>
18 #include <boost/utility/binary.hpp>
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
22 template<
typename Jo
intModel>
25 std::cout <<
"shortname: " << jmodel.
shortname() << std::endl;
27 typedef typename JointModel::ConfigVector_t ConfigVector_t;
32 ConfigVector_t ql(ConfigVector_t::Constant(jmodel.
nq(), -M_PI));
33 ConfigVector_t qu(ConfigVector_t::Constant(jmodel.
nq(), M_PI));
35 ConfigVector_t
q = LieGroupType().randomConfiguration(ql, qu);
37 pinocchio::Inertia::Matrix6 I_check = I;
38 const Eigen::VectorXd armature =
39 Eigen::VectorXd::Random(jmodel.
nv()) + Eigen::VectorXd::Ones(jmodel.
nv());
41 jmodel.
calc(jdata,
q);
42 jmodel.
calc_aba(jdata, armature, I,
true);
44 std::cout <<
"armature: " << armature.transpose() << std::endl;
45 Eigen::MatrixXd
S = jdata.S.matrix();
46 Eigen::MatrixXd U_check = I_check *
S;
47 Eigen::MatrixXd StU_check =
S.transpose() * U_check;
48 StU_check.diagonal() += armature;
49 Eigen::MatrixXd Dinv_check = StU_check.inverse();
50 Eigen::MatrixXd UDinv_check = U_check * Dinv_check;
51 Eigen::MatrixXd update_check = UDinv_check * U_check.transpose();
52 I_check -= update_check;
54 std::cout <<
"I_check:\n" << I_check << std::endl;
55 std::cout <<
"I:\n" << I << std::endl;
56 BOOST_CHECK(jdata.U.isApprox(U_check));
57 BOOST_CHECK(jdata.Dinv.isApprox(Dinv_check));
58 BOOST_CHECK(jdata.UDinv.isApprox(UDinv_check));
64 if (jmodel.
shortname() ==
"JointModelFreeFlyer")
65 BOOST_CHECK((I - I_check).
isZero());
67 BOOST_CHECK(I.isApprox(I_check));
73 template<
typename Jo
intModel>
77 jmodel.setIndexes(0, 0, 0);
87 jmodel_composite.setIndexes(0, 0, 0);
114 typedef boost::variant<
126 using namespace Eigen;
135 model.lowerPositionLimit.head<7>().
fill(-1.);
136 model.upperPositionLimit.head<7>().
fill(1.);
139 VectorXd
v = VectorXd::Ones(
model.nv);
140 VectorXd
tau = VectorXd::Zero(
model.nv);
141 VectorXd
a = VectorXd::Ones(
model.nv);
147 for (
size_t k = 1; k < (size_t)
model.njoints; ++k)
149 BOOST_CHECK(data_ref.liMi[k].isApprox(
data.liMi[k]));
150 BOOST_CHECK(data_ref.oMi[k].act(data_ref.v[k]).isApprox(
data.ov[k]));
151 BOOST_CHECK((data_ref.oMi[k].act(data_ref.a_gf[k])).isApprox(
data.oa_gf[k]));
154 BOOST_CHECK(
data.ddq.isApprox(
a, 1e-12));
159 BOOST_CHECK(data_deprecated.
ddq.isApprox(
data.ddq));
168 BOOST_CHECK(a1.isApprox(a2));
169 BOOST_CHECK(a1.isApprox(a3));
170 BOOST_CHECK(a2.isApprox(a3));
180 BOOST_CHECK(a1.isApprox(a2));
181 BOOST_CHECK(a1.isApprox(a3));
182 BOOST_CHECK(a2.isApprox(a3));
188 using namespace Eigen;
196 model.lowerPositionLimit.head<7>().
fill(-1.);
197 model.upperPositionLimit.head<7>().
fill(1.);
200 VectorXd
v = VectorXd::Random(
model.nv);
201 VectorXd
a = VectorXd::Random(
model.nv);
208 data.M.triangularView<Eigen::StrictlyLower>() =
209 data.M.transpose().triangularView<Eigen::StrictlyLower>();
216 tau -=
J.transpose() * fext[
i].toVector();
221 BOOST_CHECK(
data.ddq.isApprox(
a, 1e-12));
226 BOOST_CHECK(data_deprecated.
ddq.isApprox(
data.ddq));
231 using namespace Eigen;
240 model.lowerPositionLimit.head<7>().
fill(-1.);
241 model.upperPositionLimit.head<7>().
fill(1.);
244 VectorXd
v = VectorXd::Ones(
model.nv);
245 VectorXd
tau = VectorXd::Zero(
model.nv);
246 VectorXd
a = VectorXd::Ones(
model.nv);
250 data_ref.
M.triangularView<Eigen::StrictlyLower>() =
251 data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
253 tau = data_ref.
M *
a + data_ref.
nle;
257 BOOST_CHECK(tau_ref.isApprox(
tau, 1e-12));
258 BOOST_CHECK(
data.ddq.isApprox(
a, 1e-12));
262 BOOST_CHECK(data_deprecated.
ddq.isApprox(
a, 1e-12));
267 using namespace Eigen;
272 model.gravity.setZero();
277 model.lowerPositionLimit.head<3>().
fill(-1.);
278 model.upperPositionLimit.head<3>().
fill(1.);
280 VectorXd
v = VectorXd::Random(
model.nv);
283 data_ref.
M.triangularView<Eigen::StrictlyLower>() =
284 data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
285 MatrixXd Minv_ref(data_ref.
M.inverse());
289 BOOST_CHECK(
data.Minv.topRows<6>().isApprox(Minv_ref.topRows<6>()));
291 data.Minv.triangularView<Eigen::StrictlyLower>() =
292 data.Minv.transpose().triangularView<Eigen::StrictlyLower>();
294 BOOST_CHECK(
data.Minv.isApprox(Minv_ref));
305 using namespace Eigen;
310 model.gravity.setZero();
315 model.lowerPositionLimit.head<3>().
fill(-1.);
316 model.upperPositionLimit.head<3>().
fill(1.);
318 VectorXd
v = VectorXd::Random(
model.nv);
319 VectorXd
tau = VectorXd::Random(
model.nv);
322 data_ref.
M.triangularView<Eigen::StrictlyLower>() =
323 data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
324 MatrixXd Minv_ref(data_ref.
M.inverse());
328 BOOST_CHECK(
data.Minv.topRows<6>().isApprox(Minv_ref.topRows<6>()));
330 data.Minv.triangularView<Eigen::StrictlyLower>() =
331 data.Minv.transpose().triangularView<Eigen::StrictlyLower>();
333 BOOST_CHECK(
data.Minv.isApprox(Minv_ref));
337 data_ref2.
Minv.triangularView<Eigen::StrictlyLower>() =
338 data_ref2.
Minv.transpose().triangularView<Eigen::StrictlyLower>();
339 BOOST_CHECK(
data.Minv.isApprox(data_ref2.
Minv));
344 using namespace Eigen;
352 model.lowerPositionLimit.head<3>().
fill(-1.);
353 model.upperPositionLimit.head<3>().
fill(1.);
359 for (
int k = 0; k < 20; ++k)
364 BOOST_CHECK(data1.Minv.isApprox(data2.
Minv));
371 model.armature = Eigen::VectorXd::Random(
model.nv) + Eigen::VectorXd::Constant(
model.nv, 1.);
377 data_ref.
M.triangularView<Eigen::StrictlyLower>() =
378 data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
381 data.Minv.triangularView<Eigen::StrictlyLower>() =
382 data.Minv.transpose().triangularView<Eigen::StrictlyLower>();
384 BOOST_CHECK((
data.Minv * data_ref.
M).isIdentity());
387 BOOST_AUTO_TEST_SUITE_END()
void setIndexes(JointIndex id, int q, int v)
JointDataDerived createData() const
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
void operator()(const pinocchio::JointModelBase< pinocchio::JointModelRevoluteUnaligned > &) const
TangentVectorType ddq
The joint accelerations computed from ABA.
void operator()(const pinocchio::JointModelBase< pinocchio::JointModelComposite > &) const
JointModelFreeFlyerTpl< context::Scalar > JointModelFreeFlyer
JointModelTranslationTpl< context::Scalar > JointModelTranslation
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.
bool isZero(const Eigen::MatrixBase< MatrixLike > &m, const typename MatrixLike::RealScalar &prec=Eigen::NumTraits< typename MatrixLike::Scalar >::dummy_precision())
JointModelRevoluteTpl< context::Scalar, context::Options, 0 > JointModelRX
JointModelSphericalTpl< context::Scalar > JointModelSpherical
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & crba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Convention convention=Convention::LOCAL)
Computes the upper triangular part of the joint space inertia matrix M by using the Composite Rigid B...
void operator()(const pinocchio::JointModelBase< pinocchio::JointModelPrismaticUnaligned > &) const
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & aba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &tau, const Convention convention=Convention::LOCAL)
The Articulated-Body algorithm. It computes the forward dynamics, aka the joint accelerations given t...
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & computeJointJacobians(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the full model Jacobian, i.e. the stack of all motion subspace expressed in the world frame....
void operator()(const pinocchio::JointModelBase< JointModel > &) const
void randomConfiguration(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &lowerLimits, const Eigen::MatrixBase< ConfigVectorIn2 > &upperLimits, const Eigen::MatrixBase< ReturnType > &qout)
Generate a configuration vector uniformly sampled among provided limits.
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< VectorLike > &armature, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I=false) const
const DataTpl< Scalar, Options, JointCollectionTpl >::RowMatrixXs & computeMinverse(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the inverse of the joint space inertia matrix using Articulated Body formulation.
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
JointModelPlanarTpl< context::Scalar > JointModelPlanar
JointModelRevoluteTpl< context::Scalar, context::Options, 1 > JointModelRY
JointModelTpl< Scalar, Options > JointModel
void test_joint_methods(const pinocchio::JointModelBase< JointModel > &jmodel)
void getJointJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const JointIndex joint_id, const ReferenceFrame reference_frame, const Eigen::MatrixBase< Matrix6Like > &J)
Computes the Jacobian of a specific joint frame expressed in one of the pinocchio::ReferenceFrame opt...
RowMatrixXs Minv
The inverse of the joint space inertia matrix (a square matrix of dim model.nv).
std::string shortname() const
JointModelRevoluteTpl< context::Scalar, context::Options, 2 > JointModelRZ
JointModelPrismaticTpl< context::Scalar, context::Options, 1 > JointModelPY
static InertiaTpl Random()
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & nonLinearEffects(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the non-linear effects (Corriolis, centrifual and gravitationnal effects),...
JointModelPrismaticTpl< context::Scalar, context::Options, 2 > JointModelPZ
JointModelRevoluteUnboundedTpl< context::Scalar, context::Options, 0 > JointModelRUBX
BOOST_AUTO_TEST_CASE(test_joint_basic)
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & rnea(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &a)
The Recursive Newton-Euler algorithm. It computes the inverse dynamics, aka the joint torques accordi...
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs) const
void setIndexes(JointIndex id, int q, int v)
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
JointModelPrismaticTpl< context::Scalar, context::Options, 0 > JointModelPX
JointDataTpl< Scalar, Options > JointData
JointModelSphericalZYXTpl< context::Scalar > JointModelSphericalZYX
#define PINOCCHIO_ALIGNED_STD_VECTOR(Type)
JointModelRevoluteUnalignedTpl< context::Scalar > JointModelRevoluteUnaligned
JointModelPrismaticUnalignedTpl< context::Scalar > JointModelPrismaticUnaligned
Main pinocchio namespace.
VectorXs nle
Vector of Non Linear Effects (dim model.nv). It corresponds to concatenation of the Coriolis,...
JointModelRevoluteUnboundedTpl< context::Scalar, context::Options, 1 > JointModelRUBY
pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:05