unittest/compute-all-terms.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
17 
18 #include <boost/test/unit_test.hpp>
19 
20 using namespace pinocchio;
21 
22 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
23 
24 void run_test(const Model & model, const Eigen::VectorXd & q, const Eigen::VectorXd & v)
25 {
27  pinocchio::Data data_other(model);
28 
30 
31  nonLinearEffects(model, data_other, q, v);
32  crba(model, data_other, q, Convention::WORLD);
33  getJacobianComFromCrba(model, data_other);
35  centerOfMass(model, data_other, q, v, true);
36  computeKineticEnergy(model, data_other, q, v);
37  computePotentialEnergy(model, data_other, q);
38  dccrba(model, data_other, q, v);
39  computeGeneralizedGravity(model, data_other, q);
40 
41  BOOST_CHECK(data.nle.isApprox(data_other.nle));
42  BOOST_CHECK(Eigen::MatrixXd(data.M.triangularView<Eigen::Upper>())
43  .isApprox(Eigen::MatrixXd(data_other.M.triangularView<Eigen::Upper>())));
44  BOOST_CHECK(data.J.isApprox(data_other.J));
45  BOOST_CHECK(data.dJ.isApprox(data_other.dJ));
46  BOOST_CHECK(data.Jcom.isApprox(data_other.Jcom));
47  BOOST_CHECK(data.Ag.isApprox(data_other.Ag));
48  BOOST_CHECK(data.dAg.isApprox(data_other.dAg));
49  BOOST_CHECK(data.hg.isApprox(data_other.hg));
50  BOOST_CHECK(data.Ig.isApprox(data_other.Ig));
51  BOOST_CHECK(data.g.isApprox(data_other.g));
52 
53  for (int k = 0; k < model.njoints; ++k)
54  {
55  BOOST_CHECK(data.com[(size_t)k].isApprox(data_other.com[(size_t)k]));
56  BOOST_CHECK(data.vcom[(size_t)k].isApprox(data_other.vcom[(size_t)k]));
57  BOOST_CHECK_CLOSE(data.mass[(size_t)k], data_other.mass[(size_t)k], 1e-12);
58  }
59 
60  BOOST_CHECK_CLOSE(data.kinetic_energy, data_other.kinetic_energy, 1e-12);
61  BOOST_CHECK_CLOSE(data.potential_energy, data_other.potential_energy, 1e-12);
62 }
63 
64 BOOST_AUTO_TEST_CASE(test_against_algo)
65 {
66  using namespace Eigen;
67 
70 
71  VectorXd q(VectorXd::Random(model.nq));
72  VectorXd v(VectorXd::Random(model.nv));
73 
74  // -------
75  q.setZero();
76  v.setZero();
77 
78  run_test(model, q, v);
79 
80  // -------
81  q.setZero();
82  v.setOnes();
83 
84  run_test(model, q, v);
85 
86  // -------
87  q.setOnes();
88  q.segment<4>(3).normalize();
89  v.setOnes();
90 
91  run_test(model, q, v);
92 
93  // -------
94  q.setRandom();
95  q.segment<4>(3).normalize();
96  v.setRandom();
97 
98  run_test(model, q, v);
99 }
100 
101 BOOST_AUTO_TEST_SUITE_END()
pinocchio::DataTpl::M
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
Definition: multibody/data.hpp:199
fwd.hpp
pinocchio::computePotentialEnergy
Scalar computePotentialEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Computes the potential energy of the system, i.e. the potential energy linked to the gravity field....
pinocchio::DataTpl::g
VectorXs g
Vector of generalized gravity (dim model.nv).
Definition: multibody/data.hpp:184
Eigen
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::DataTpl::dAg
Matrix6x dAg
Centroidal Momentum Matrix Time Variation.
Definition: multibody/data.hpp:290
pinocchio::DataTpl::mass
std::vector< Scalar > mass
Vector of subtree mass. In other words, mass[j] is the mass of the subtree supported by joint ....
Definition: multibody/data.hpp:444
compute-all-terms.hpp
pinocchio::DataTpl::dJ
Matrix6x dJ
Derivative of the Jacobian with respect to the time.
Definition: multibody/data.hpp:363
pinocchio::DataTpl::kinetic_energy
Scalar kinetic_energy
Kinetic energy of the system.
Definition: multibody/data.hpp:453
pinocchio::Convention::WORLD
@ WORLD
model.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
pinocchio::buildModels::humanoidRandom
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
pinocchio::crba
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...
pinocchio::computeJointJacobiansTimeVariation
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...
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_against_algo)
Definition: unittest/compute-all-terms.cpp:64
visitor.hpp
pinocchio::dccrba
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...
rnea.hpp
timer.hpp
pinocchio::DataTpl::potential_energy
Scalar potential_energy
Potential energy of the system.
Definition: multibody/data.hpp:456
se3.hpp
data.hpp
pinocchio::DataTpl::Jcom
Matrix3x Jcom
Jacobian of center of mass.
Definition: multibody/data.hpp:450
pinocchio::DataTpl::Ag
Matrix6x Ag
Centroidal Momentum Matrix.
Definition: multibody/data.hpp:284
pinocchio::nonLinearEffects
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),...
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
pinocchio::getJacobianComFromCrba
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...
pinocchio::computeKineticEnergy
Scalar computeKineticEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Computes the kinetic energy of the system. The result is accessible through data.kinetic_energy.
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1084
pinocchio::DataTpl::J
Matrix6x J
Jacobian of joint placements.
Definition: multibody/data.hpp:360
centroidal.hpp
pinocchio::DataTpl::hg
Force hg
Centroidal momentum quantity.
Definition: multibody/data.hpp:297
sample-models.hpp
jacobian.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
run_test
void run_test(const Model &model, const Eigen::VectorXd &q, const Eigen::VectorXd &v)
Definition: unittest/compute-all-terms.cpp:24
crba.hpp
pinocchio::computeAllTerms
void computeAllTerms(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Computes efficiently all the terms needed for dynamic simulation. It is equivalent to the call at the...
pinocchio::DataTpl::Ig
Inertia Ig
Centroidal Composite Rigid Body Inertia.
Definition: multibody/data.hpp:310
pinocchio::normalize
void normalize(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &qout)
Normalize a configuration vector.
Definition: joint-configuration.hpp:887
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::DataTpl::nle
VectorXs nle
Vector of Non Linear Effects (dim model.nv). It corresponds to concatenation of the Coriolis,...
Definition: multibody/data.hpp:179
pinocchio::computeGeneralizedGravity
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::centerOfMass
const DataTpl< Scalar, Options, JointCollectionTpl >::Vector3 & centerOfMass(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const bool computeSubtreeComs=true)
Computes the center of mass position of a given model according to a particular joint configuration....


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:28