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
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32