parallel-rnea.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 INRIA
3 //
4 
5 #include "pinocchio/spatial/fwd.hpp"
6 #include "pinocchio/algorithm/parallel/rnea.hpp"
7 #include "pinocchio/algorithm/rnea.hpp"
8 #include "pinocchio/algorithm/joint-configuration.hpp"
9 #include "pinocchio/parsers/sample-models.hpp"
10 #include "pinocchio/utils/timer.hpp"
11 
12 #include <iostream>
13 
14 #include <boost/test/unit_test.hpp>
15 #include <boost/utility/binary.hpp>
16 
17 using namespace pinocchio;
18 
19 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
20 
21 BOOST_AUTO_TEST_CASE(test_parallel_rnea)
22 {
24  Data data_ref(model);
25 
26  model.lowerPositionLimit.head<3>().fill(-1.);
27  model.upperPositionLimit.head<3>().fill( 1.);
28 
29  const Eigen::DenseIndex batch_size = 128;
30  const int num_thread = omp_get_max_threads();
31 
32  Eigen::MatrixXd q(model.nq,batch_size);
33  Eigen::MatrixXd v(model.nv,batch_size);
34  Eigen::MatrixXd a(model.nv,batch_size);
35  Eigen::MatrixXd tau(model.nv,batch_size);
36  Eigen::MatrixXd tau_ref(model.nv,batch_size);
37 
38  for(Eigen::DenseIndex i = 0; i < batch_size; ++i)
39  {
40  q.col(i) = randomConfiguration(model);
41  v.col(i) = Eigen::VectorXd::Random(model.nv);
42  a.col(i) = Eigen::VectorXd::Random(model.nv);
43  }
44 
45  ModelPool pool(model,num_thread);
46  rnea(num_thread,pool,q,v,a,tau);
47 
48  for(Eigen::DenseIndex i = 0; i < batch_size; ++i)
49  {
50  tau_ref.col(i) = rnea(model,data_ref,q.col(i),v.col(i),a.col(i));
51  }
52 
53  BOOST_CHECK(tau == tau_ref);
54 
55 }
56 
57 BOOST_AUTO_TEST_SUITE_END()
58 
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
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...
ConfigVectorType lowerPositionLimit
Lower joint configuration limit.
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.
fill
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Vec3f a
Main pinocchio namespace.
Definition: timings.cpp:28
int nv
Dimension of the velocity vector space.
BOOST_AUTO_TEST_CASE(test_parallel_rnea)
ConfigVectorType upperPositionLimit
Upper joint configuration limit.
void humanoidRandom(ModelTpl< Scalar, Options, JointCollectionTpl > &model, bool usingFF=true)
Create a humanoid kinematic tree with 6-DOF limbs and random joint placements.
JointCollectionTpl & model
int nq
Dimension of the configuration vector representation.


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32