5 #include "pinocchio/spatial/fwd.hpp" 6 #include "pinocchio/spatial/se3.hpp" 7 #include "pinocchio/multibody/visitor.hpp" 8 #include "pinocchio/multibody/model.hpp" 9 #include "pinocchio/multibody/data.hpp" 10 #include "pinocchio/algorithm/joint-configuration.hpp" 11 #include "pinocchio/algorithm/crba.hpp" 12 #include "pinocchio/algorithm/aba.hpp" 13 #include "pinocchio/algorithm/cholesky.hpp" 14 #include "pinocchio/parsers/urdf.hpp" 15 #include "pinocchio/parsers/sample-models.hpp" 19 #include "pinocchio/utils/timer.hpp" 21 #include <Eigen/StdVector> 24 int
main(
int argc, const
char ** argv)
26 using namespace Eigen;
31 const int NBT = 1000*100;
34 std::cout <<
"(the time score in debug mode is not relevant) " << std::endl;
40 if(argc>1) filename = argv[1];
45 std::cout <<
"nq = " << model.
nq << std::endl;
48 VectorXd qmax = Eigen::VectorXd::Ones(model.
nq);
50 MatrixXd
A(model.
nv,model.
nv), B(model.
nv,model.
nv);
51 A.setZero(); B.setRandom();
53 std::vector<VectorXd> qs (NBT);
54 std::vector<VectorXd> lhs (NBT);
55 std::vector<VectorXd> rhs (NBT);
56 for(
size_t i=0;
i<NBT;++
i)
59 lhs[
i] = Eigen::VectorXd::Zero(model.
nv);
60 rhs[
i] = Eigen::VectorXd::Random(model.
nv);
66 crba(model,data,qs[_smooth]);
71 std::cout <<
"Cholesky = \t" << (total/NBT)
75 Eigen::LDLT<Eigen::MatrixXd> Mldlt(data.
M);
78 crba(model,data,qs[_smooth]);
79 data.
M.triangularView<Eigen::StrictlyLower>()
80 = data.
M.transpose().triangularView<Eigen::StrictlyLower>();
82 Mldlt.compute(data.
M);
85 std::cout <<
"Dense Eigen Cholesky = \t" << (total/NBT)
93 std::cout <<
"Cholesky solve vector = \t\t"; timer.
toc(std::cout,NBT);
100 std::cout <<
"UDUtv = \t\t"; timer.
toc(std::cout,NBT);
102 MatrixXd Minv(model.
nv,model.
nv); Minv.setZero();
108 std::cout <<
"Minv from cholesky = \t\t"; timer.
toc(std::cout,NBT);
115 std::cout <<
"Cholesky solve column = \t\t"; timer.
toc(std::cout,NBT);
120 lhs[_smooth].noalias() = Minv*rhs[_smooth];
122 std::cout <<
"Minv*v = \t\t"; timer.
toc(std::cout,NBT);
127 A.noalias() = Minv*B;
129 std::cout <<
"A = Minv*B = \t\t"; timer.
toc(std::cout,NBT);
131 data.
M.triangularView<Eigen::StrictlyLower>()
132 = data.
M.transpose().triangularView<Eigen::StrictlyLower>();
136 A.noalias() = data.
M.inverse();
138 std::cout <<
"M.inverse() = \t\t"; timer.
toc(std::cout,NBT);
145 std::cout <<
"computeMinverse = \t\t"; timer.
toc(std::cout,NBT);
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & crba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the upper triangular part of the joint space inertia matrix M by using the Composite Rigid B...
Mat & computeMinv(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Mat > &Minv)
Computes the inverse of the joint space inertia matrix M from its Cholesky factorization.
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.
const DataTpl< Scalar, Options, JointCollectionTpl >::MatrixXs & decompose(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Compute the Cholesky decomposition of the joint space inertia matrix M contained in data...
static std::string unitName(Unit u)
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.
#define PINOCCHIO_MODEL_DIR
int main(int argc, const char **argv)
MatrixXs M
The joint space inertia matrix (a square matrix of dim model.nv).
ModelTpl< Scalar, Options, JointCollectionTpl > & buildModel(const std::string &filename, const typename ModelTpl< Scalar, Options, JointCollectionTpl >::JointModel &rootJoint, ModelTpl< Scalar, Options, JointCollectionTpl > &model, const bool verbose=false)
Build the model from a URDF file with a particular joint as root of the model tree inside the model g...
Main pinocchio namespace.
Mat & UDUtv(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Mat > &m)
Performs the multiplication by using the Cholesky decomposition of M stored in data.
int nv
Dimension of the velocity vector space.
Mat & solve(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Mat > &y)
Return the solution of using the Cholesky decomposition stored in data given the entry ...
JointModelFreeFlyerTpl< double > JointModelFreeFlyer
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorXd
int nq
Dimension of the configuration vector representation.