multibody/geometry.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2023 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_geometry_hpp__
6 #define __pinocchio_multibody_geometry_hpp__
7 
10 
12 
13 #include <map>
14 #include <list>
15 #include <utility>
16 #include <assert.h>
17 
18 namespace pinocchio
19 {
20 
21  struct CollisionPair : public std::pair<GeomIndex, GeomIndex>
22  {
23 
24  typedef std::pair<GeomIndex, GeomIndex> Base;
25 
27  CollisionPair();
28 
36  CollisionPair(const GeomIndex co1, const GeomIndex co2);
37  bool operator==(const CollisionPair & rhs) const;
38  bool operator!=(const CollisionPair & rhs) const;
39  void disp(std::ostream & os) const;
40  friend std::ostream & operator<<(std::ostream & os, const CollisionPair & X);
41 
42  }; // struct CollisionPair
43 
44  template<>
46  {
48  };
49 
51  : NumericalBase<GeometryModel>
52  , serialization::Serializable<GeometryModel>
53  {
54  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
55 
57  enum
58  {
60  };
61 
63 
64  typedef ::pinocchio::GeometryObject GeometryObject;
65  typedef PINOCCHIO_ALIGNED_STD_VECTOR(GeometryObject) GeometryObjectVector;
66  typedef std::vector<CollisionPair> CollisionPairVector;
67  typedef Eigen::Matrix<bool, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXb;
68  typedef Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXi;
69 
71 
73  : ngeoms(0)
74  , geometryObjects()
75  , collisionPairs()
76  {
77  }
78 
79  GeometryModel(const GeometryModel & other) = default;
80 
82 
92  template<typename S2, int O2, template<typename, int> class _JointCollectionTpl>
95 
104 
112  void removeGeometryObject(const std::string & name);
113 
121  GeomIndex getGeometryId(const std::string & name) const;
122 
130  bool existGeometryName(const std::string & name) const;
131 
138  void addCollisionPair(const CollisionPair & pair);
139 
145  void addAllCollisionPairs();
146 
155  void setCollisionPairs(const MatrixXb & collision_map, const bool upper = true);
156 
162  void removeCollisionPair(const CollisionPair & pair);
163 
168 
177  bool existCollisionPair(const CollisionPair & pair) const;
178 
186  PairIndex findCollisionPair(const CollisionPair & pair) const;
187 
191  GeometryModel clone() const;
192 
196  bool operator==(const GeometryModel & other) const
197  {
198  return ngeoms == other.ngeoms && geometryObjects == other.geometryObjects
199  && collisionPairs == other.collisionPairs
201  }
202 
206  bool operator!=(const GeometryModel & other) const
207  {
208  return !(*this == other);
209  }
210 
211  friend std::ostream & operator<<(std::ostream & os, const GeometryModel & model_geom);
212 
215 
217  GeometryObjectVector geometryObjects;
218 
221 
224 
225  }; // struct GeometryModel
226 
227  template<>
229  {
231  };
232 
234  : NumericalBase<GeometryData>
235  , serialization::Serializable<GeometryData>
236  {
237  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
238 
240  enum
241  {
243  };
244 
246  typedef std::vector<GeomIndex> GeomIndexList;
247  typedef Eigen::Matrix<bool, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXb;
248  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXs;
249 
250 #ifdef PINOCCHIO_WITH_HPP_FCL
251  typedef ::pinocchio::ComputeCollision ComputeCollision;
252  typedef ::pinocchio::ComputeDistance ComputeDistance;
253 #endif
254 
263 
267  std::vector<bool> activeCollisionPairs;
268 
269 #ifdef PINOCCHIO_WITH_HPP_FCL
270 
274  std::vector<fcl::DistanceRequest> distanceRequests;
275 
279  std::vector<fcl::DistanceResult> distanceResults;
280 
284  std::vector<fcl::CollisionRequest> collisionRequests;
285 
289  std::vector<fcl::CollisionResult> collisionResults;
290 
295  std::vector<Scalar> radius;
296 
303  PairIndex collisionPairIndex;
304 
306  PINOCCHIO_ALIGNED_STD_VECTOR(ComputeCollision) collision_functors;
307 
309  PINOCCHIO_ALIGNED_STD_VECTOR(ComputeDistance) distance_functors;
310 
311 #endif // PINOCCHIO_WITH_HPP_FCL
312 
318  std::map<JointIndex, GeomIndexList> innerObjects;
319 
324  std::map<JointIndex, GeomIndexList> outerObjects;
325 
331  explicit GeometryData(const GeometryModel & geom_model);
332 
338  GeometryData(const GeometryData & other);
339 
345  GeometryData & operator=(const GeometryData & other);
346 
349 
351  ~GeometryData();
352 
362  void fillInnerOuterObjectMaps(const GeometryModel & geomModel);
363 
377  void activateCollisionPair(const PairIndex pair_id);
378 
386 
396  const GeometryModel & geom_model, const MatrixXb & collision_map, const bool upper = true);
397 
407  const GeometryModel & geom_model, const GeomIndex geom_id, bool enable_collision);
408 
418  void deactivateCollisionPair(const PairIndex pair_id);
419 
427 
428 #ifdef PINOCCHIO_WITH_HPP_FCL
429  void setSecurityMargins(
440  const GeometryModel & geom_model,
441  const MatrixXs & security_margin_map,
442  const bool upper = true,
443  const bool sync_distance_upper_bound = false);
444 
445 #endif // ifdef PINOCCHIO_WITH_HPP_FCL
446 
447  friend std::ostream & operator<<(std::ostream & os, const GeometryData & geomData);
448 
452  bool operator==(const GeometryData & other) const
453  {
454  return oMg == other.oMg && activeCollisionPairs == other.activeCollisionPairs
455 #ifdef PINOCCHIO_WITH_HPP_FCL
456  && distanceRequests == other.distanceRequests
457  && distanceResults == other.distanceResults
458  && collisionRequests == other.collisionRequests
459  && collisionResults == other.collisionResults && radius == other.radius
460  && collisionPairIndex == other.collisionPairIndex
461 #endif
462  && innerObjects == other.innerObjects && outerObjects == other.outerObjects;
463  }
464 
468  bool operator!=(const GeometryData & other) const
469  {
470  return !(*this == other);
471  }
472 
473  }; // struct GeometryData
474 
475 } // namespace pinocchio
476 
477 /* --- Details -------------------------------------------------------------- */
478 /* --- Details -------------------------------------------------------------- */
479 /* --- Details -------------------------------------------------------------- */
480 #include "pinocchio/multibody/geometry.hxx"
481 
482 #endif // ifndef __pinocchio_multibody_geometry_hpp__
pinocchio::GeometryModel::SE3
SE3Tpl< Scalar, Options > SE3
Definition: multibody/geometry.hpp:62
pinocchio::GeometryData::MatrixXs
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXs
Definition: multibody/geometry.hpp:248
pinocchio::GeometryModel::clone
GeometryModel clone() const
Create a deep copy of *this.
pinocchio::GeometryModel::getGeometryId
GeomIndex getGeometryId(const std::string &name) const
Return the index of a GeometryObject given by its name.
pinocchio::NumericalBase
Definition: fwd.hpp:89
pinocchio::GeometryModel::addCollisionPair
void addCollisionPair(const CollisionPair &pair)
Add a collision pair into the vector of collision_pairs. The method check before if the given Collisi...
pinocchio::GeometryData::Options
@ Options
Definition: multibody/geometry.hpp:242
pinocchio::GeometryData::setActiveCollisionPairs
void setActiveCollisionPairs(const GeometryModel &geom_model, const MatrixXb &collision_map, const bool upper=true)
Set the collision pair association from a given input array. Each entry of the input matrix defines t...
pinocchio::GeometryModel::GeomIndex
pinocchio::GeomIndex GeomIndex
Definition: multibody/geometry.hpp:70
pinocchio::GeometryData::MatrixXb
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXb
Definition: multibody/geometry.hpp:247
pinocchio::GeometryModel::PINOCCHIO_ALIGNED_STD_VECTOR
typedef PINOCCHIO_ALIGNED_STD_VECTOR(GeometryObject) GeometryObjectVector
pinocchio::GeometryData::fillInnerOuterObjectMaps
void fillInnerOuterObjectMaps(const GeometryModel &geomModel)
pinocchio::GeometryData::PINOCCHIO_ALIGNED_STD_VECTOR
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) oMg
Vector gathering the SE3 placements of the geometry objects relative to the world....
aligned-vector.hpp
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::GeometryModel::removeGeometryObject
void removeGeometryObject(const std::string &name)
Remove a GeometryObject.
pinocchio::name
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
pinocchio::GeometryModel::GeometryObject
::pinocchio::GeometryObject GeometryObject
Definition: multibody/geometry.hpp:64
pinocchio::GeometryData::activateCollisionPair
void activateCollisionPair(const PairIndex pair_id)
serializable.hpp
pinocchio::CollisionPair::Base
std::pair< GeomIndex, GeomIndex > Base
Definition: multibody/geometry.hpp:24
pinocchio::GeometryData::GeometryData
GeometryData()
Empty constructor.
Definition: multibody/geometry.hpp:348
pinocchio::GeometryData::operator==
bool operator==(const GeometryData &other) const
Returns true if *this and other are equal.
Definition: multibody/geometry.hpp:452
pinocchio::GeometryModel::CollisionPairVector
std::vector< CollisionPair > CollisionPairVector
Definition: multibody/geometry.hpp:66
pinocchio::GeometryModel::operator==
bool operator==(const GeometryModel &other) const
Returns true if *this and other are equal.
Definition: multibody/geometry.hpp:196
pinocchio::GeometryObject
Definition: multibody/geometry-object.hpp:87
pinocchio::CollisionPair::operator<<
friend std::ostream & operator<<(std::ostream &os, const CollisionPair &X)
pinocchio::GeometryData::outerObjects
std::map< JointIndex, GeomIndexList > outerObjects
A list of associated collision GeometryObjects to a given joint Id.
Definition: multibody/geometry.hpp:324
pinocchio::GeometryData::~GeometryData
~GeometryData()
Destructor.
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
pinocchio::GeometryModel::addAllCollisionPairs
void addAllCollisionPairs()
Add all possible collision pairs.
pinocchio::GeometryModel::existCollisionPair
bool existCollisionPair(const CollisionPair &pair) const
Check if a collision pair exists in collisionPairs. See also findCollisitionPair(const CollisionPair ...
pinocchio::GeometryModel::removeAllCollisionPairs
void removeAllCollisionPairs()
Remove all collision pairs from collisionPairs. Same as collisionPairs.clear().
pinocchio::GeometryData::operator=
GeometryData & operator=(const GeometryData &other)
Copy operator.
pinocchio::GeometryModel::operator<<
friend std::ostream & operator<<(std::ostream &os, const GeometryModel &model_geom)
pinocchio::traits< GeometryData >::Scalar
context::Scalar Scalar
Definition: multibody/geometry.hpp:230
pinocchio::Index
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
Definition: multibody/fwd.hpp:22
pinocchio::GeometryModel::Scalar
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef context::Scalar Scalar
Definition: multibody/geometry.hpp:56
pinocchio::GeometryModel::geometryObjects
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.
Definition: multibody/geometry.hpp:217
pinocchio::traits< GeometryModel >::Scalar
context::Scalar Scalar
Definition: multibody/geometry.hpp:47
pinocchio::CollisionPair
Definition: multibody/geometry.hpp:21
pinocchio::GeometryModel::collisionPairMapping
MatrixXi collisionPairMapping
Matrix relating the collision pair ID to a pair of two GeometryObject indexes.
Definition: multibody/geometry.hpp:223
pinocchio::GeometryData::activeCollisionPairs
std::vector< bool > activeCollisionPairs
Vector of collision pairs.
Definition: multibody/geometry.hpp:267
pinocchio::GeometryModel::~GeometryModel
~GeometryModel()
Definition: multibody/geometry.hpp:81
pinocchio::GeometryModel::findCollisionPair
PairIndex findCollisionPair(const CollisionPair &pair) const
Return the index of a given collision pair in collisionPairs.
pinocchio::PairIndex
Index PairIndex
Definition: multibody/fwd.hpp:29
pinocchio::GeometryData::deactivateAllCollisionPairs
void deactivateAllCollisionPairs()
Deactivate all collision pairs.
pinocchio::CollisionPair::CollisionPair
CollisionPair()
Empty constructor.
geometry-object.hpp
pinocchio::GeometryModel::ngeoms
Index ngeoms
The number of GeometryObjects.
Definition: multibody/geometry.hpp:214
pinocchio::GeometryModel::MatrixXi
Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXi
Definition: multibody/geometry.hpp:68
pinocchio::GeometryData::setGeometryCollisionStatus
void setGeometryCollisionStatus(const GeometryModel &geom_model, const GeomIndex geom_id, bool enable_collision)
Enable or disable collision for the given geometry given by its geometry id with all the other geomet...
pinocchio::GeometryData::operator<<
friend std::ostream & operator<<(std::ostream &os, const GeometryData &geomData)
pinocchio::CollisionPair::operator==
bool operator==(const CollisionPair &rhs) const
append-urdf-model-with-another-model.geom_model
geom_model
Definition: append-urdf-model-with-another-model.py:25
pinocchio::GeometryData::operator!=
bool operator!=(const GeometryData &other) const
Returns true if *this and other are not equal.
Definition: multibody/geometry.hpp:468
pinocchio::context::Options
@ Options
Definition: context/generic.hpp:45
pinocchio::GeometryData::deactivateCollisionPair
void deactivateCollisionPair(const PairIndex pair_id)
pinocchio::GeometryModel::addGeometryObject
GeomIndex addGeometryObject(const GeometryObject &object, const ModelTpl< S2, O2, _JointCollectionTpl > &model)
Add a geometry object to a GeometryModel and set its parent joint.
pinocchio::GeometryData::innerObjects
std::map< JointIndex, GeomIndexList > innerObjects
Map over vector GeomModel::geometryObjects, indexed by joints.
Definition: multibody/geometry.hpp:318
pinocchio::GeometryData::activateAllCollisionPairs
void activateAllCollisionPairs()
Activate all collision pairs.
pinocchio::GeometryModel::collisionPairs
CollisionPairVector collisionPairs
Vector of collision pairs.
Definition: multibody/geometry.hpp:220
pinocchio::GeometryModel::GeometryModel
GeometryModel()
Definition: multibody/geometry.hpp:72
pinocchio::GeometryModel::MatrixXb
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXb
Definition: multibody/geometry.hpp:67
pinocchio::CollisionPair::disp
void disp(std::ostream &os) const
pinocchio::GeometryData::SE3
SE3Tpl< Scalar, Options > SE3
Definition: multibody/geometry.hpp:245
pinocchio::GeometryData::GeomIndexList
std::vector< GeomIndex > GeomIndexList
Definition: multibody/geometry.hpp:246
pinocchio::GeometryModel::operator!=
bool operator!=(const GeometryModel &other) const
Returns true if *this and other are not equal.
Definition: multibody/geometry.hpp:206
pinocchio::GeometryModel::existGeometryName
bool existGeometryName(const std::string &name) const
Check if a GeometryObject given by its name exists.
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::traits
Common traits structure to fully define base classes for CRTP.
Definition: fwd.hpp:71
pinocchio::GeometryData::Scalar
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef context::Scalar Scalar
Definition: multibody/geometry.hpp:239
pinocchio::GeometryModel::removeCollisionPair
void removeCollisionPair(const CollisionPair &pair)
Remove if exists the CollisionPair from the vector collision_pairs.
pinocchio::GeometryModel::setCollisionPairs
void setCollisionPairs(const MatrixXb &collision_map, const bool upper=true)
Set the collision pairs from a given input array. Each entry of the input matrix defines the activati...
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::GeometryModel::Options
@ Options
Definition: multibody/geometry.hpp:59
pinocchio::GeomIndex
Index GeomIndex
Definition: multibody/fwd.hpp:27
X
pinocchio::context::Scalar
PINOCCHIO_SCALAR_TYPE Scalar
Definition: context/generic.hpp:42
pinocchio::serialization::Serializable
Definition: serialization/serializable.hpp:16
radius
FCL_REAL radius
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
simulation-closed-kinematic-chains.rhs
rhs
Definition: simulation-closed-kinematic-chains.py:138
pinocchio::CollisionPair::operator!=
bool operator!=(const CollisionPair &rhs) const
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:44