forked from stack-of-tasks/pinocchio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-algo-in-parallel.py
More file actions
31 lines (24 loc) · 926 Bytes
/
run-algo-in-parallel.py
File metadata and controls
31 lines (24 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pinocchio as pin
import numpy as np
model = pin.buildSampleModelHumanoid()
model.lowerPositionLimit[:7] = -np.ones(7)
model.upperPositionLimit[:7] = +np.ones(7)
pool = pin.ModelPool(model)
num_threads = pin.omp_get_max_threads()
batch_size = 128
q = np.empty((model.nq,batch_size))
for k in range(batch_size):
q[:,k] = pin.randomConfiguration(model)
v = np.zeros((model.nv,batch_size))
a = np.zeros((model.nv,batch_size))
tau = np.zeros((model.nv,batch_size))
print("num_threads: {}".format(num_threads))
print("batch_size: {}".format(batch_size))
# Call RNEA
res_rnea = np.empty((model.nv,batch_size))
pin.rnea(num_threads,pool,q,v,a,res_rnea) # Without allocation
res_rnea2 = pin.rnea(num_threads,pool,q,v,a) # With allocation
# Call ABA
res_aba = np.empty((model.nv,batch_size))
pin.aba(num_threads,pool,q,v,tau,res_aba) # Without allocation
res_aba2 = pin.aba(num_threads,pool,q,v,tau) # With allocation