run-algo-in-parallel.py
Go to the documentation of this file.
1 import numpy as np
2 import pinocchio as pin
3 
4 model = pin.buildSampleModelHumanoid()
5 model.lowerPositionLimit[:7] = -np.ones(7)
6 model.upperPositionLimit[:7] = +np.ones(7)
7 
8 pool = pin.ModelPool(model)
9 
10 num_threads = pin.omp_get_max_threads()
11 batch_size = 128
12 q = np.empty((model.nq, batch_size))
13 for k in range(batch_size):
14  q[:, k] = pin.randomConfiguration(model)
15 
16 v = np.zeros((model.nv, batch_size))
17 a = np.zeros((model.nv, batch_size))
18 tau = np.zeros((model.nv, batch_size))
19 
20 print(f"num_threads: {num_threads}")
21 print(f"batch_size: {batch_size}")
22 
23 # Call RNEA
24 res_rnea = np.empty((model.nv, batch_size))
25 pin.rneaInParallel(num_threads, pool, q, v, a, res_rnea) # Without allocation
26 res_rnea2 = pin.rneaInParallel(num_threads, pool, q, v, a) # With allocation
27 
28 # Call ABA
29 res_aba = np.empty((model.nv, batch_size))
30 pin.abaInParallel(num_threads, pool, q, v, tau, res_aba) # Without allocation
31 res_aba2 = pin.abaInParallel(num_threads, pool, q, v, tau) # With allocation
pinocchio::randomConfiguration
void randomConfiguration(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const Eigen::MatrixBase< ConfigOut_t > &qout)
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
pinocchio::ModelPoolTpl
Definition: multibody/pool/fwd.hpp:17
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


pinocchio
Author(s):
autogenerated on Wed May 28 2025 02:41:21