multibody/pool/geometry.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2022 INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_pool_geometry_hpp__
6 #define __pinocchio_multibody_pool_geometry_hpp__
7 
10 
11 namespace pinocchio
12 {
13  template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl>
14  class GeometryPoolTpl : public ModelPoolTpl<_Scalar, _Options, JointCollectionTpl>
15  {
16  public:
17  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
18 
20  typedef _Scalar Scalar;
21  enum
22  {
23  Options = _Options
24  };
25 
26  typedef typename Base::Model Model;
27  typedef typename Base::Data Data;
28  typedef typename Base::ModelVector ModelVector;
29  typedef typename Base::DataVector DataVector;
30  typedef ::pinocchio::GeometryModel GeometryModel;
31  typedef ::pinocchio::GeometryData GeometryData;
32 
33  typedef std::vector<GeometryModel, Eigen::aligned_allocator<GeometryModel>> GeometryModelVector;
34  typedef std::vector<GeometryData, Eigen::aligned_allocator<GeometryData>> GeometryDataVector;
35 
43  const Model & model,
44  const GeometryModel & geometry_model,
45  const size_t pool_size = (size_t)omp_get_max_threads())
46  : Base(model, pool_size)
47  {
48  m_geometry_models.reserve(pool_size);
49  m_geometry_datas.reserve(pool_size);
50  for (size_t k = 0; k < pool_size; ++k)
51  {
52  m_geometry_models.push_back(geometry_model.clone());
54 
55  typedef typename GeometryData::SE3 SE3;
56  for (SE3 & oMg_i : m_geometry_datas.back().oMg)
57  {
58  oMg_i.setIdentity();
59  }
60  }
61  }
62 
68  : Base(other)
69  {
70  const size_t pool_size = other.size();
71  m_geometry_models.reserve(pool_size);
72  m_geometry_datas.reserve(pool_size);
73  for (size_t k = 0; k < pool_size; ++k)
74  {
75  m_geometry_models.push_back(other.m_geometry_models[k].clone());
77  }
78  }
79 
81  const GeometryModel & getGeometryModel(const size_t index) const
82  {
84  index < m_geometry_models.size(),
85  "Index greater than the size of the geometry_models vector.");
86  return m_geometry_models[index];
87  }
88 
90  GeometryModel & getGeometryModel(const size_t index)
91  {
93  index < m_geometry_models.size(),
94  "Index greater than the size of the geometry_models vector.");
95  return m_geometry_models[index];
96  }
97 
99  const GeometryData & getGeometryData(const size_t index) const
100  {
102  index < m_geometry_datas.size(),
103  "Index greater than the size of the geometry_datas vector.");
104  return m_geometry_datas[index];
105  }
106 
108  GeometryData & getGeometryData(const size_t index)
109  {
111  index < m_geometry_datas.size(),
112  "Index greater than the size of the geometry_datas vector.");
113  return m_geometry_datas[index];
114  }
115 
118  {
119  return m_geometry_datas;
120  }
121 
124  {
125  return m_geometry_datas;
126  }
127 
130  {
131  return m_geometry_models;
132  }
133 
136  {
137  return m_geometry_models;
138  }
139 
140  using Base::size;
141  using Base::update;
142 
145  void sync(const GeometryModel & geometry_model, const std::vector<GeomIndex> & geometry_indexes)
146  {
147  for (GeomIndex i : geometry_indexes)
149  i < geometry_model.ngeoms,
150  "One of the given geometry index is greater than geometry_model.ngeoms.");
151 
152  for (GeometryModel & geometry_model_pool : m_geometry_models)
153  {
154  for (GeomIndex i : geometry_indexes)
155  geometry_model_pool.geometryObjects[i] = geometry_model.geometryObjects[i].clone();
156  }
157  }
158 
164  virtual void update(const GeometryData & geometry_data_to_copy)
165  {
166  for (GeometryData & geometry_data : m_geometry_datas)
167  {
168  geometry_data.oMg = geometry_data_to_copy.oMg;
169  geometry_data.activeCollisionPairs = geometry_data_to_copy.activeCollisionPairs;
170  geometry_data.distanceRequests = geometry_data_to_copy.distanceRequests;
171  geometry_data.collisionRequests = geometry_data_to_copy.collisionRequests;
172  geometry_data.collisionPairIndex = geometry_data_to_copy.collisionPairIndex;
173  }
174  }
175 
177  virtual ~GeometryPoolTpl() {};
178 
179  protected:
182 
185 
187  virtual void doResize(const size_t new_size)
188  {
189  const size_t current_size = (size_t)size();
190  m_geometry_models.resize((size_t)new_size);
191  m_geometry_datas.resize((size_t)new_size);
192  if (current_size < new_size)
193  {
194  for (size_t k = current_size; k < new_size; ++k)
195  {
196  m_geometry_models[k] = m_geometry_models[0].clone();
198  }
199  }
200  }
201  };
202 
203 } // namespace pinocchio
204 
205 #endif // ifndef __pinocchio_multibody_pool_geometry_hpp__
pinocchio::GeometryPoolTpl::getGeometryModels
const GeometryModelVector & getGeometryModels() const
Returns the vector of Geometry Model.
Definition: multibody/pool/geometry.hpp:129
pinocchio::GeometryModel::clone
GeometryModel clone() const
Create a deep copy of *this.
pinocchio::GeometryPoolTpl::ModelVector
Base::ModelVector ModelVector
Definition: multibody/pool/geometry.hpp:28
pinocchio::GeometryPoolTpl::getGeometryData
const GeometryData & getGeometryData(const size_t index) const
Returns the geometry_data at given index.
Definition: multibody/pool/geometry.hpp:99
pinocchio::GeometryPoolTpl::GeometryPoolTpl
GeometryPoolTpl(const Model &model, const GeometryModel &geometry_model, const size_t pool_size=(size_t) omp_get_max_threads())
Default constructor from a model and a pool size.
Definition: multibody/pool/geometry.hpp:42
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
Macro to check an assert-like condition and throw a std::invalid_argument exception (with a message) ...
Definition: include/pinocchio/macros.hpp:192
pinocchio::GeometryPoolTpl::GeometryModelVector
std::vector< GeometryModel, Eigen::aligned_allocator< GeometryModel > > GeometryModelVector
Definition: multibody/pool/geometry.hpp:33
index
index
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::GeometryPoolTpl::~GeometryPoolTpl
virtual ~GeometryPoolTpl()
&#160;
Definition: multibody/pool/geometry.hpp:177
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
pinocchio::GeometryPoolTpl::GeometryData
::pinocchio::GeometryData GeometryData
Definition: multibody/pool/geometry.hpp:31
pinocchio::GeometryPoolTpl::getGeometryModel
GeometryModel & getGeometryModel(const size_t index)
Returns the geometry_model at given index.
Definition: multibody/pool/geometry.hpp:90
pinocchio::GeometryPoolTpl::GeometryPoolTpl
GeometryPoolTpl(const GeometryPoolTpl &other)
Copy constructor from an other GeometryPoolTpl.
Definition: multibody/pool/geometry.hpp:67
pinocchio::GeometryPoolTpl::DataVector
Base::DataVector DataVector
Definition: multibody/pool/geometry.hpp:29
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
pinocchio::GeometryPoolTpl::m_geometry_models
GeometryModelVector m_geometry_models
Vector of Geometry Model associated to the pool.
Definition: multibody/pool/geometry.hpp:177
pinocchio::python::context::Model
ModelTpl< Scalar, Options > Model
Definition: bindings/python/context/generic.hpp:63
pinocchio::GeometryPoolTpl::Scalar
_Scalar Scalar
Definition: multibody/pool/geometry.hpp:20
pinocchio::GeometryPoolTpl::update
virtual void update(const GeometryData &geometry_data_to_copy)
Update the geometry datas with the new value.
Definition: multibody/pool/geometry.hpp:164
pinocchio::GeometryModel::geometryObjects
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.
Definition: multibody/geometry.hpp:217
pinocchio::python::context::Data
DataTpl< Scalar, Options > Data
Definition: bindings/python/context/generic.hpp:64
pinocchio::GeometryPoolTpl::Model
Base::Model Model
Definition: multibody/pool/geometry.hpp:26
pinocchio::GeometryPoolTpl::Options
@ Options
Definition: multibody/pool/geometry.hpp:23
pinocchio::GeometryPoolTpl::getGeometryData
GeometryData & getGeometryData(const size_t index)
Returns the geometry_data at given index.
Definition: multibody/pool/geometry.hpp:108
pinocchio::GeometryData::activeCollisionPairs
std::vector< bool > activeCollisionPairs
Vector of collision pairs.
Definition: multibody/geometry.hpp:267
pinocchio::GeometryPoolTpl::Base
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ModelPoolTpl< _Scalar, _Options, JointCollectionTpl > Base
Definition: multibody/pool/geometry.hpp:19
size
FCL_REAL size() const
pinocchio::ModelPoolTpl
Definition: multibody/pool/fwd.hpp:17
geometry.hpp
pinocchio::GeometryPoolTpl::GeometryModel
::pinocchio::GeometryModel GeometryModel
Definition: multibody/pool/geometry.hpp:30
model.hpp
pinocchio::GeometryPoolTpl::m_geometry_datas
GeometryDataVector m_geometry_datas
Vector of Geometry Data associated to the pool.
Definition: multibody/pool/geometry.hpp:184
pinocchio::GeometryPoolTpl::getGeometryModel
const GeometryModel & getGeometryModel(const size_t index) const
Returns the geometry_model at given index.
Definition: multibody/pool/geometry.hpp:81
pinocchio::GeometryModel::ngeoms
Index ngeoms
The number of GeometryObjects.
Definition: multibody/geometry.hpp:214
update
AABB & update(const Vec3f &a, const Vec3f &b)
pinocchio::GeometryPoolTpl::GeometryDataVector
std::vector< GeometryData, Eigen::aligned_allocator< GeometryData > > GeometryDataVector
Definition: multibody/pool/geometry.hpp:34
pinocchio::GeometryPoolTpl::getGeometryDatas
const GeometryDataVector & getGeometryDatas() const
Returns the vector of Geometry Data.
Definition: multibody/pool/geometry.hpp:117
pinocchio::GeometryPoolTpl::getGeometryModels
GeometryModelVector & getGeometryModels()
Returns the vector of Geometry Model.
Definition: multibody/pool/geometry.hpp:135
pinocchio::GeometryPoolTpl::Data
Base::Data Data
Definition: multibody/pool/geometry.hpp:27
pinocchio::GeometryPoolTpl::getGeometryDatas
GeometryDataVector & getGeometryDatas()
Returns the vector of Geometry Data.
Definition: multibody/pool/geometry.hpp:123
pinocchio::GeometryPoolTpl::doResize
virtual void doResize(const size_t new_size)
&#160;
Definition: multibody/pool/geometry.hpp:187
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::GeometryPoolTpl::sync
void sync(const GeometryModel &geometry_model, const std::vector< GeomIndex > &geometry_indexes)
Synchronize the internal geometry models with the input geometry for all given geometry indexes by cl...
Definition: multibody/pool/geometry.hpp:145
Base
pinocchio::SE3
SE3Tpl< context::Scalar, context::Options > SE3
Definition: spatial/fwd.hpp:64
pinocchio::SE3Tpl::setIdentity
SE3Tpl & setIdentity()
Definition: spatial/se3-tpl.hpp:141
pinocchio::GeomIndex
Index GeomIndex
Definition: multibody/fwd.hpp:27
pinocchio::GeometryPoolTpl
Definition: multibody/pool/fwd.hpp:24
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Mon Dec 16 2024 03:41:02