Go to the documentation of this file.
31 #include <pmmintrin.h>
34 #include <boost/test/unit_test.hpp>
35 #include <boost/utility/binary.hpp>
39 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
44 _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
46 using namespace Eigen;
52 model.lowerPositionLimit.head<3>().
fill(-1.);
53 model.upperPositionLimit.head<3>().
fill(1.);
56 data.v[0] = Motion::Zero();
60 VectorXd
v = VectorXd::Random(
model.nv);
61 VectorXd
a = VectorXd::Random(
model.nv);
64 const size_t NBT = 10000;
67 std::cout <<
"(the time score in debug mode is not relevant) ";
76 timer.
toc(std::cout, NBT);
81 using namespace Eigen;
87 model.lowerPositionLimit.head<3>().
fill(-1.);
88 model.upperPositionLimit.head<3>().
fill(1.);
94 VectorXd
v = VectorXd::Random(
model.nv);
96 VectorXd tau_nle(VectorXd::Zero(
model.nv));
100 q.tail(
model.nq - 7).setZero();
106 BOOST_CHECK(tau_nle.isApprox(
tau_rnea, 1e-12));
109 q.tail(
model.nq - 7).setZero();
115 BOOST_CHECK(tau_nle.isApprox(
tau_rnea, 1e-12));
118 q.tail(
model.nq - 7).setOnes();
124 BOOST_CHECK(tau_nle.isApprox(
tau_rnea, 1e-12));
133 BOOST_CHECK(tau_nle.isApprox(
tau_rnea, 1e-12));
138 using namespace Eigen;
144 model.lowerPositionLimit.head<3>().
fill(-1.);
145 model.upperPositionLimit.head<3>().
fill(1.);
152 VectorXd
v(VectorXd::Random(
model.nv));
153 VectorXd
a(VectorXd::Random(
model.nv));
158 Force Frf = Force::Random();
161 Force Flf = Force::Random();
165 VectorXd tau_ref(data_rnea.
tau);
168 tau_ref -= Jrf.transpose() * Frf.toVector();
172 tau_ref -= Jlf.transpose() * Flf.toVector();
176 BOOST_CHECK(tau_ref.isApprox(data_rnea_fext.
tau));
181 using namespace Eigen;
186 model.armature = VectorXd::Random(
model.nv) + VectorXd::Ones(
model.nv);
188 model.lowerPositionLimit.head<3>().
fill(-1.);
189 model.upperPositionLimit.head<3>().
fill(1.);
195 VectorXd
v(VectorXd::Random(
model.nv));
196 VectorXd
a(VectorXd::Random(
model.nv));
199 data_ref.
M.triangularView<StrictlyLower>() =
200 data_ref.
M.transpose().triangularView<StrictlyLower>();
203 const VectorXd tau_ref = data_ref.
M *
a +
nle;
206 BOOST_CHECK(tau_ref.isApprox(
data.tau));
211 using namespace Eigen;
217 model.lowerPositionLimit.head<3>().
fill(-1.);
218 model.upperPositionLimit.head<3>().
fill(1.);
228 BOOST_CHECK(data_rnea.
tau.isApprox(
data.g));
236 BOOST_CHECK(g_ref.isApprox(
data.g));
241 using namespace Eigen;
247 model.lowerPositionLimit.head<3>().
fill(-1.);
248 model.upperPositionLimit.head<3>().
fill(1.);
256 ForceVector fext((
size_t)
model.njoints);
257 for (ForceVector::iterator
it = fext.begin();
it != fext.end(); ++
it)
263 BOOST_CHECK(data_rnea.
tau.isApprox(
data.tau));
277 static_torque_ref -= J_local.transpose() * fext[
joint_id].toVector();
280 BOOST_CHECK(static_torque_ref.isApprox(
data.tau));
285 using namespace Eigen;
288 const double prec = Eigen::NumTraits<double>::dummy_precision();
293 model.lowerPositionLimit.head<3>().
fill(-1.);
294 model.upperPositionLimit.head<3>().
fill(1.);
301 VectorXd
v(VectorXd::Random(
model.nv));
303 BOOST_CHECK(
data.C.isZero(prec));
305 model.gravity.setZero();
310 BOOST_CHECK(
data.dJ.isApprox(data_ref.
dJ));
311 BOOST_CHECK(
data.J.isApprox(data_ref.
J));
314 BOOST_CHECK(
tau.isApprox(data_ref.
tau, prec));
320 Motion vcom(data_ref.vcom[0], Data::Vector3::Zero());
322 cM1.translation() -=
com;
324 BOOST_CHECK((cM1.toDualActionMatrix() * data_ref.
M.topRows<6>()).isApprox(data_ref.
Ag, prec));
328 BOOST_CHECK(dh.isApprox(dh_ref, prec));
332 Eigen::MatrixXd
dM(
data.C +
data.C.transpose());
334 const double alpha = 1e-8;
335 Eigen::VectorXd q_plus(
model.nq);
339 data_ref.
M.triangularView<Eigen::StrictlyLower>() =
340 data_ref.
M.transpose().triangularView<Eigen::StrictlyLower>();
342 data_ref_plus.
M.triangularView<Eigen::StrictlyLower>() =
343 data_ref_plus.
M.transpose().triangularView<Eigen::StrictlyLower>();
345 Eigen::MatrixXd dM_ref = (data_ref_plus.
M - data_ref.
M) /
alpha;
346 BOOST_CHECK(
dM.isApprox(dM_ref, sqrt(
alpha)));
357 const Eigen::MatrixXd &
G = mimic_test_case.
G;
364 Eigen::VectorXd
v = Eigen::VectorXd::Random(
model_mimic.nv);
365 Eigen::VectorXd
a = Eigen::VectorXd::Random(
model_mimic.nv);
374 data_full.M.triangularView<Eigen::StrictlyLower>() =
375 data_full.M.transpose().triangularView<Eigen::StrictlyLower>();
379 Eigen::VectorXd tau_ref =
G.transpose() *
data_full.M *
G *
a + (
G.transpose() *
nle);
381 BOOST_CHECK(tau_ref.isApprox(data_rnea_mimic.
tau));
386 Eigen::VectorXd tau_ref_nle =
389 BOOST_CHECK(tau_nle.isApprox(tau_ref_nle));
398 BOOST_CHECK(tau_gg.isApprox(tau_ref_gg));
403 for (ForceVector::iterator
it = fext.begin();
it != fext.end(); ++
it)
412 BOOST_CHECK(tau_st.isApprox(data_ref_st.
tau));
416 BOOST_AUTO_TEST_SUITE_END()
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
Matrix6x dAg
Centroidal Momentum Matrix Time Variation.
std::vector< Scalar > mass
Vector of subtree mass. In other words, mass[j] is the mass of the subtree supported by joint ....
void toFull(const Eigen::VectorXd &q, Eigen::VectorXd &q_full) const
Matrix6x dJ
Derivative of the Jacobian with respect to the time.
ForceTpl< Scalar, Options > Force
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...
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & computeJointJacobiansTimeVariation(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the full model Jacobian variations with respect to time. It corresponds to dJ/dt which depen...
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....
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & dccrba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the time derivative of the Centroidal Momentum Matrix according to the current configuration...
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true, bool mimic=false)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
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.
Eigen::Matrix< Scalar, 3, Eigen::Dynamic, Options > Matrix3x
The 3d jacobian type (temporary)
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
Integrate a configuration vector for the specified model for a tangent vector during one unit time.
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & computeStaticTorque(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const container::aligned_vector< ForceTpl< Scalar, Options >> &fext)
Computes the generalized static torque contribution of the Lagrangian dynamics:
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...
TangentVectorType tau
Vector of joint torques (dim model.nv).
BOOST_AUTO_TEST_CASE(test_rnea)
pinocchio::Model model_mimic
Matrix6x Ag
Centroidal Momentum Matrix.
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),...
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix3x & getJacobianComFromCrba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Extracts both the jacobian of the center of mass (CoM), the total mass of the system and the CoM posi...
static const Vector3 gravity981
Default 3D gravity vector (=(0,0,-9.81)).
Matrix6x J
Jacobian of joint placements.
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 computeJointJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const JointIndex joint_id, const Eigen::MatrixBase< Matrix6Like > &J)
Computes the Jacobian of a specific joint frame expressed in the local frame of the joint and store t...
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
#define PINOCCHIO_ALIGNED_STD_VECTOR(Type)
pinocchio::Model model_full
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & computeCoriolisMatrix(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes the Coriolis Matrix of the Lagrangian dynamics:
Main pinocchio namespace.
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & computeGeneralizedGravity(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the generalized gravity contribution of the Lagrangian dynamics:
pinocchio
Author(s):
autogenerated on Wed Apr 16 2025 02:41:50