bindings/python/collision/parallel/broadphase.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2024 INRIA
3 //
4 
9 
17 
19 
20 namespace pinocchio
21 {
22  namespace python
23  {
24 
25  namespace bp = boost::python;
26  using namespace Eigen;
27 
28  typedef Eigen::Matrix<bool, Eigen::Dynamic, 1> VectorXb;
29 
30  template<typename BroadPhaseManager>
32  const size_t num_threads,
34  const Eigen::MatrixBase<Eigen::MatrixXd> & q,
35  const bool stopAtFirstCollisionInConfiguration = false,
36  const bool stopAtFirstCollisionInBatch = false)
37  {
38  VectorXb res(q.cols());
40  num_threads, pool, q, res, stopAtFirstCollisionInConfiguration,
41  stopAtFirstCollisionInBatch);
42  return res;
43  }
44 
45  template<typename BroadPhaseManager>
46  std::vector<VectorXb> computeCollisionsInParallel_2(
47  const size_t num_threads,
49  const std::vector<Eigen::MatrixXd> & trajectories,
50  const bool stopAtFirstCollisionInTrajectory = false)
51  {
52  std::vector<VectorXb> res(trajectories.size());
53  for (size_t k = 0; k < trajectories.size(); ++k)
54  {
55  res[k].resize(trajectories[k].cols());
56  }
58  num_threads, pool, trajectories, res, stopAtFirstCollisionInTrajectory);
59  return res;
60  }
61 
62  template<typename BroadPhaseManager>
63  void exposeCase()
64  {
65  bp::def(
66  "computeCollisionsInParallel", computeCollisionsInParallel_1<BroadPhaseManager>,
67  (bp::arg("num_thread"), bp::arg("pool"), bp::arg("q"),
68  bp::arg("stop_at_first_collision_in_configuration") = false,
69  bp::arg("stop_at_first_collision_in_batch") = false),
70  "Evaluates in parallel the batch of configurations and returns the result.\n\n"
71  "Parameters:\n"
72  "\tnum_thread: number of threads used for the computation\n"
73  "\tpool: the broadphase manager pool\n"
74  "\tq: the batch of joint configurations\n"
75  "\tstop_at_first_collision_in_configuration: if set to true, stops when encountering "
76  "the first collision in a configuration\n"
77  "\tstop_at_first_collision_in_batch: if set to true, stops when encountering the "
78  "first collision in a batch.\n");
79 
80  bp::def(
81  "computeCollisionsInParallel", computeCollisionsInParallel_2<BroadPhaseManager>,
82  (bp::arg("num_thread"), bp::arg("pool"), bp::arg("trajectories"),
83  bp::arg("stop_at_first_collision_in_trajectory") = false),
84  "Evaluates in parallel the batch of trajectories and returns a vector of vector of Boolean "
85  "containing the status for each configuration contained in a given trajectory.\n\n"
86  "Parameters:\n"
87  "\tnum_thread: number of threads used for the computation\n"
88  "\tpool: the broadphase manager pool\n"
89  "\ttrajectories: the list of joint trajectories\n"
90  "\tstop_at_first_collision_in_trajectory: if set to true, stops when encountering the "
91  "first collision in a given trajectory.\n");
92  }
93 
95  {
96  exposeCase<BroadPhaseManagerTpl<hpp::fcl::DynamicAABBTreeCollisionManager>>();
97  exposeCase<TreeBroadPhaseManagerTpl<hpp::fcl::DynamicAABBTreeCollisionManager>>();
98  }
99 
100  } // namespace python
101 } // namespace pinocchio
broadphase_dynamic_AABB_tree.h
broadphase_dynamic_AABB_tree_array.h
boost::python
Eigen
pinocchio::python::computeCollisionsInParallel_2
std::vector< VectorXb > computeCollisionsInParallel_2(const size_t num_threads, BroadPhaseManagerPoolBase< BroadPhaseManager, double > &pool, const std::vector< Eigen::MatrixXd > &trajectories, const bool stopAtFirstCollisionInTrajectory=false)
Definition: bindings/python/collision/parallel/broadphase.cpp:46
pinocchio::BroadPhaseManagerPoolBase
Definition: collision/pool/broadphase-manager.hpp:21
broadphase_bruteforce.h
eigen-from-python.hpp
run-algo-in-parallel.num_threads
num_threads
Definition: run-algo-in-parallel.py:10
tree-broadphase-manager.hpp
algorithms.hpp
broadphase_SSaP.h
python
pinocchio::python::computeCollisionsInParallel_1
VectorXb computeCollisionsInParallel_1(const size_t num_threads, BroadPhaseManagerPoolBase< BroadPhaseManager, double > &pool, const Eigen::MatrixBase< Eigen::MatrixXd > &q, const bool stopAtFirstCollisionInConfiguration=false, const bool stopAtFirstCollisionInBatch=false)
Definition: bindings/python/collision/parallel/broadphase.cpp:31
run-algo-in-parallel.pool
pool
Definition: run-algo-in-parallel.py:8
pinocchio::python::exposeCase
void exposeCase()
Definition: bindings/python/collision/parallel/broadphase.cpp:63
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
pinocchio::python::VectorXb
Eigen::Matrix< bool, Eigen::Dynamic, 1 > VectorXb
Definition: bindings/python/collision/parallel/broadphase.cpp:28
pinocchio::computeCollisionsInParallel
void computeCollisionsInParallel(const size_t num_threads, BroadPhaseManagerPoolBase< BroadPhaseManagerDerived, Scalar, Options, JointCollectionTpl > &pool, const Eigen::MatrixBase< ConfigVectorPool > &q, const Eigen::MatrixBase< CollisionVectorResult > &res, const bool stopAtFirstCollisionInConfiguration=false, const bool stopAtFirstCollisionInBatch=false)
Definition: parallel/broadphase.hpp:25
broadphase_SaP.h
cols
int cols
std-vector.hpp
broadphase_interval_tree.h
pinocchio::python::res
ReturnType res
Definition: bindings/python/spatial/explog.hpp:68
pinocchio::python::exposeParallelBroadPhase
void exposeParallelBroadPhase()
Definition: bindings/python/collision/parallel/broadphase.cpp:94
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
broadphase_spatialhash.h
broadphase.hpp


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