parallel-rnea.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2022 INRIA
3 //
4 
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 {
25  Data data_ref(model);
26 
27  model.lowerPositionLimit.head<3>().fill(-1.);
28  model.upperPositionLimit.head<3>().fill(1.);
29 
30  const Eigen::DenseIndex batch_size = 128;
31  const size_t num_thread = (size_t)omp_get_max_threads();
32 
33  Eigen::MatrixXd q(model.nq, batch_size);
34  Eigen::MatrixXd v(model.nv, batch_size);
35  Eigen::MatrixXd a(model.nv, batch_size);
36  Eigen::MatrixXd tau(model.nv, batch_size);
37  Eigen::MatrixXd tau_ref(model.nv, batch_size);
38 
39  for (Eigen::DenseIndex i = 0; i < batch_size; ++i)
40  {
41  q.col(i) = randomConfiguration(model);
42  v.col(i) = Eigen::VectorXd::Random(model.nv);
43  a.col(i) = Eigen::VectorXd::Random(model.nv);
44  }
45 
46  ModelPool pool(model, num_thread);
47  rneaInParallel(num_thread, pool, q, v, a, tau);
48 
49  for (Eigen::DenseIndex i = 0; i < batch_size; ++i)
50  {
51  tau_ref.col(i) = rnea(model, data_ref, q.col(i), v.col(i), a.col(i));
52  }
53 
54  BOOST_CHECK(tau == tau_ref);
55 }
56 
57 BOOST_AUTO_TEST_SUITE_END()
fwd.hpp
pinocchio::DataTpl
Definition: context/generic.hpp:25
rnea.hpp
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
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.
run-algo-in-parallel.batch_size
int batch_size
Definition: run-algo-in-parallel.py:11
pinocchio::randomConfiguration
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.
Definition: joint-configuration.hpp:315
rnea.hpp
timer.hpp
forward-dynamics-derivatives.tau
tau
Definition: forward-dynamics-derivatives.py:25
joint-configuration.hpp
pinocchio::ModelPoolTpl
Definition: multibody/pool/fwd.hpp:17
run-algo-in-parallel.pool
pool
Definition: run-algo-in-parallel.py:8
pinocchio::rneaInParallel
void rneaInParallel(const size_t 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...
Definition: parallel/rnea.hpp:39
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_parallel_rnea)
Definition: parallel-rnea.cpp:21
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
a
Vec3f a
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1084
fill
fill
pinocchio::rnea
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...
sample-models.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:47