5 #include "pinocchio/codegen/cppadcg.hpp" 7 #include "pinocchio/algorithm/joint-configuration.hpp" 8 #include "pinocchio/algorithm/crba.hpp" 9 #include "pinocchio/algorithm/centroidal.hpp" 10 #include "pinocchio/algorithm/aba.hpp" 11 #include "pinocchio/algorithm/rnea.hpp" 12 #include "pinocchio/algorithm/cholesky.hpp" 13 #include "pinocchio/algorithm/jacobian.hpp" 14 #include "pinocchio/algorithm/center-of-mass.hpp" 15 #include "pinocchio/algorithm/compute-all-terms.hpp" 16 #include "pinocchio/algorithm/kinematics.hpp" 17 #include "pinocchio/parsers/urdf.hpp" 18 #include "pinocchio/parsers/sample-models.hpp" 19 #include "pinocchio/container/aligned-vector.hpp" 21 #include "pinocchio/codegen/code-generator-algo.hpp" 25 #include "pinocchio/utils/timer.hpp" 27 int main(
int argc,
const char ** argv)
29 using namespace Eigen;
34 const int NBT = 1000*100;
37 std::cout <<
"(the time score in debug mode is not relevant) " << std::endl;
42 if(argc>1) filename = argv[1];
47 const std::string ff_option = argv[2];
48 if(ff_option ==
"-no-ff")
60 std::cout <<
"nq = " << model.
nq << std::endl;
61 std::cout <<
"nv = " << model.
nv << std::endl;
62 std::cout <<
"--" << std::endl;
65 VectorXd qmax = Eigen::VectorXd::Ones(model.
nq);
84 rnea_derivatives_code_gen.
initLib();
85 rnea_derivatives_code_gen.
loadLib();
88 aba_derivatives_code_gen.
initLib();
89 aba_derivatives_code_gen.
loadLib();
96 for(
size_t i=0;
i<NBT;++
i)
99 qdots[
i] = Eigen::VectorXd::Random(model.
nv);
100 qddots[
i] = Eigen::VectorXd::Random(model.
nv);
101 taus[
i] = Eigen::VectorXd::Random(model.
nv);
107 rnea(model,data,qs[_smooth],qdots[_smooth],qddots[_smooth]);
109 std::cout <<
"RNEA = \t\t"; timer.
toc(std::cout,NBT);
114 rnea_code_gen.
evalFunction(qs[_smooth],qdots[_smooth],qddots[_smooth]);
116 std::cout <<
"RNEA generated = \t\t"; timer.
toc(std::cout,NBT);
121 rnea_code_gen.
evalJacobian(qs[_smooth],qdots[_smooth],qddots[_smooth]);
123 std::cout <<
"RNEA partial derivatives auto diff + code gen = \t\t"; timer.
toc(std::cout,NBT);
128 rnea_derivatives_code_gen.
evalFunction(qs[_smooth],qdots[_smooth],qddots[_smooth]);
130 std::cout <<
"RNEA partial derivatives code gen = \t\t"; timer.
toc(std::cout,NBT);
135 aba(model,data,qs[_smooth],qdots[_smooth],taus[_smooth]);
142 crba(model,data,qs[_smooth]);
144 std::cout <<
"CRBA = \t\t"; timer.
toc(std::cout,NBT);
151 std::cout <<
"CRBA generated = \t\t"; timer.
toc(std::cout,NBT);
158 std::cout <<
"Minv = \t\t"; timer.
toc(std::cout,NBT);
165 std::cout <<
"Minv generated = \t\t"; timer.
toc(std::cout,NBT);
170 aba(model,data,qs[_smooth],qdots[_smooth],taus[_smooth]);
172 std::cout <<
"ABA = \t\t"; timer.
toc(std::cout,NBT);
177 aba_code_gen.
evalFunction(qs[_smooth],qdots[_smooth],taus[_smooth]);
179 std::cout <<
"ABA generated = \t\t"; timer.
toc(std::cout,NBT);
184 aba_code_gen.
evalJacobian(qs[_smooth],qdots[_smooth],taus[_smooth]);
186 std::cout <<
"ABA partial derivatives auto diff + code gen = \t\t"; timer.
toc(std::cout,NBT);
191 aba_derivatives_code_gen.
evalFunction(qs[_smooth],qdots[_smooth],qddots[_smooth]);
193 std::cout <<
"ABA partial derivatives code gen = \t\t"; timer.
toc(std::cout,NBT);
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)
The Articulated-Body algorithm. It computes the forward dynamics, aka the joint accelerations given t...
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...
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.
void rnea(const int num_threads, ModelPoolTpl< Scalar, Options, JointCollectionTpl > &pool, const Eigen::MatrixBase< ConfigVectorPool > &q, const Eigen::MatrixBase< TangentVectorPool1 > &v, const Eigen::MatrixBase< TangentVectorPool2 > &a, const Eigen::MatrixBase< TangentVectorPool3 > &tau)
The Recursive Newton-Euler algorithm. It computes the inverse dynamics, aka the joint torques accordi...
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q)
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
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &a)
void loadLib(const bool generate_if_not_exist=true)
Specialization of an std::vector with an aligned allocator. This specialization might be used when th...
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &tau)
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &a)
void evalJacobian(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &tau)
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...
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &tau)
Main pinocchio namespace.
int nv
Dimension of the velocity vector space.
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
void evalFunction(const Eigen::MatrixBase< ConfigVectorType > &q)
int nq
Dimension of the configuration vector representation.
void evalJacobian(const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVector1 > &v, const Eigen::MatrixBase< TangentVector2 > &a)
int main(int argc, const char **argv)