parallel-aba.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_aba)
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_threads = (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 tau(model.nv, batch_size);
36  Eigen::MatrixXd a(model.nv, batch_size);
37  Eigen::MatrixXd a_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  tau.col(i) = Eigen::VectorXd::Random(model.nv);
44  }
45 
48 
49  for (Eigen::DenseIndex i = 0; i < batch_size; ++i)
50  {
51  a_ref.col(i) = aba(model, data_ref, q.col(i), v.col(i), tau.col(i), Convention::WORLD);
52  }
53 
54  BOOST_CHECK(a == a_ref);
55 }
56 
57 BOOST_AUTO_TEST_SUITE_END()
fwd.hpp
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::Convention::WORLD
@ WORLD
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
run-algo-in-parallel.num_threads
num_threads
Definition: run-algo-in-parallel.py:10
aba.hpp
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::aba
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, const Convention convention=Convention::LOCAL)
The Articulated-Body algorithm. It computes the forward dynamics, aka the joint accelerations given t...
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
timer.hpp
pinocchio::abaInParallel
void abaInParallel(const size_t num_threads, ModelPoolTpl< Scalar, Options, JointCollectionTpl > &pool, const Eigen::MatrixBase< ConfigVectorPool > &q, const Eigen::MatrixBase< TangentVectorPool1 > &v, const Eigen::MatrixBase< TangentVectorPool2 > &tau, const Eigen::MatrixBase< TangentVectorPool3 > &a)
A parallel version of the Articulated Body algorithm. It computes the forward dynamics,...
Definition: algorithm/parallel/aba.hpp:40
aba.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::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
sample-models.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_parallel_aba)
Definition: parallel-aba.cpp:21
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


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