src/multibody/geometry.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_geometry_hpp__
6 #define __pinocchio_multibody_geometry_hpp__
7 
8 #include "pinocchio/multibody/fcl.hpp"
9 #include "pinocchio/multibody/fwd.hpp"
10 #include "pinocchio/container/aligned-vector.hpp"
11 
12 #include "pinocchio/serialization/serializable.hpp"
13 
14 #include <map>
15 #include <list>
16 #include <utility>
17 #include <assert.h>
18 
19 namespace pinocchio
20 {
21 
23  {
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
26  typedef double Scalar;
27  enum { Options = 0 };
28 
30 
31  typedef ::pinocchio::GeometryObject GeometryObject;
32  typedef PINOCCHIO_ALIGNED_STD_VECTOR(GeometryObject) GeometryObjectVector;
34  typedef Eigen::Matrix<bool,Eigen::Dynamic,Eigen::Dynamic,Options> MatrixXb;
35 
37 
39  : ngeoms(0)
40  , geometryObjects()
41  , collisionPairs()
42  {}
43 
45 
55  template<typename S2, int O2, template<typename,int> class _JointCollectionTpl>
56  GeomIndex addGeometryObject(const GeometryObject & object,
58 
66  GeomIndex addGeometryObject(const GeometryObject & object);
67 
75  GeomIndex getGeometryId(const std::string & name) const;
76 
77 
85  bool existGeometryName(const std::string & name) const;
86 
93  void addCollisionPair(const CollisionPair & pair);
94 
100  void addAllCollisionPairs();
101 
110  void setCollisionPairs(const MatrixXb & collision_map,
111  const bool upper = true);
112 
118  void removeCollisionPair(const CollisionPair& pair);
119 
124 
133  bool existCollisionPair(const CollisionPair & pair) const;
134 
142  PairIndex findCollisionPair(const CollisionPair & pair) const;
143 
147  bool operator==(const GeometryModel & other) const
148  {
149  return
150  ngeoms == other.ngeoms
151  && geometryObjects == other.geometryObjects
152  && collisionPairs == other.collisionPairs
153  ;
154  }
155 
159  bool operator!=(const GeometryModel & other) const
160  {
161  return !(*this == other);
162  }
163 
164  friend std::ostream& operator<<(std::ostream & os,
165  const GeometryModel & model_geom);
166 
169 
171  GeometryObjectVector geometryObjects;
172 
175 
176  }; // struct GeometryModel
177 
179  : serialization::Serializable<GeometryData>
180  {
181  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
182 
183  typedef double Scalar;
184  enum { Options = 0 };
185 
187  typedef std::vector<GeomIndex> GeomIndexList;
188  typedef Eigen::Matrix<bool,Eigen::Dynamic,Eigen::Dynamic,Options> MatrixXb;
189  typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic,Options> MatrixXs;
190 
191 #ifdef PINOCCHIO_WITH_HPP_FCL
192  typedef ::pinocchio::ComputeCollision ComputeCollision;
193  typedef ::pinocchio::ComputeDistance ComputeDistance;
194 #endif
195 
204 
208  std::vector<bool> activeCollisionPairs;
209 
210 #ifdef PINOCCHIO_WITH_HPP_FCL
211 
215  std::vector<fcl::DistanceRequest> distanceRequests;
216 
220  std::vector<fcl::DistanceResult> distanceResults;
221 
225  std::vector<fcl::CollisionRequest> collisionRequests;
226 
230  std::vector<fcl::CollisionResult> collisionResults;
231 
236  std::vector<Scalar> radius;
237 
244  PairIndex collisionPairIndex;
245 
247  PINOCCHIO_ALIGNED_STD_VECTOR(ComputeCollision) collision_functors;
248 
250  PINOCCHIO_ALIGNED_STD_VECTOR(ComputeDistance) distance_functors;
251 
252 #endif // PINOCCHIO_WITH_HPP_FCL
253 
258  std::map<JointIndex,GeomIndexList> innerObjects;
259 
264  std::map<JointIndex,GeomIndexList> outerObjects;
265 
271  explicit GeometryData(const GeometryModel & geom_model);
272 
278  GeometryData(const GeometryData & other);
279 
282 
284  ~GeometryData();
285 
295  void fillInnerOuterObjectMaps(const GeometryModel & geomModel);
296 
310  void activateCollisionPair(const PairIndex pair_id);
311 
317  void activateAllCollisionPairs();
318 
327  void setActiveCollisionPairs(const GeometryModel & geom_model,
328  const MatrixXb & collision_map,
329  const bool upper = true);
330 
338  void setGeometryCollisionStatus(const GeometryModel & geom_model,
339  const GeomIndex geom_id,
340  bool enable_collision);
341 
351  void deactivateCollisionPair(const PairIndex pair_id);
352 
358  void deactivateAllCollisionPairs();
359 
360 #ifdef PINOCCHIO_WITH_HPP_FCL
361  void setSecurityMargins(const GeometryModel & geom_model,
369  const MatrixXs & security_margin_map,
370  const bool upper = true);
371 #endif // ifdef PINOCCHIO_WITH_HPP_FCL
372 
373  friend std::ostream & operator<<(std::ostream & os, const GeometryData & geomData);
374 
378  bool operator==(const GeometryData & other) const
379  {
380  return
381  oMg == other.oMg
382  && activeCollisionPairs == other.activeCollisionPairs
383 #ifdef PINOCCHIO_WITH_HPP_FCL
384  && distanceRequests == other.distanceRequests
385  && distanceResults == other.distanceResults
386  && collisionRequests == other.collisionRequests
387  && collisionResults == other.collisionResults
388  && radius == other.radius
389  && collisionPairIndex == other.collisionPairIndex
390 #endif
391  && innerObjects == other.innerObjects
392  && outerObjects == other.outerObjects
393  ;
394  }
395 
399  bool operator!=(const GeometryData & other) const
400  {
401  return !(*this == other);
402  }
403 
404  }; // struct GeometryData
405 
406 } // namespace pinocchio
407 
408 /* --- Details -------------------------------------------------------------- */
409 /* --- Details -------------------------------------------------------------- */
410 /* --- Details -------------------------------------------------------------- */
411 #include "pinocchio/multibody/geometry.hxx"
412 
413 #endif // ifndef __pinocchio_multibody_geometry_hpp__
bool operator==(const GeometryData &other) const
Returns true if *this and other are equal.
bool existGeometryName(const std::string &name) const
Check if a GeometryObject given by its name exists.
GeometryData()
Empty constructor.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef double Scalar
bool operator!=(const GeometryData &other) const
Returns true if *this and other are not equal.
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXb
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXb
bool operator!=(const GeometryModel &other) const
Returns true if *this and other are not equal.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef double Scalar
SE3Tpl< Scalar, Options > SE3
CollisionPairVector collisionPairs
Vector of collision pairs.
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
std::map< JointIndex, GeomIndexList > innerObjects
Map over vector GeomModel::geometryObjects, indexed by joints.
std::vector< bool > activeCollisionPairs
Vector of collision pairs.
void removeCollisionPair(const CollisionPair &pair)
Remove if exists the CollisionPair from the vector collision_pairs.
PairIndex findCollisionPair(const CollisionPair &pair) const
Return the index of a given collision pair in collisionPairs.
std::vector< GeomIndex > GeomIndexList
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.
bool operator==(const GeometryModel &other) const
Returns true if *this and other are equal.
bool existCollisionPair(const CollisionPair &pair) const
Check if a collision pair exists in collisionPairs. See also findCollisitionPair(const CollisionPair ...
std::map< JointIndex, GeomIndexList > outerObjects
A list of associated collision GeometryObjects to a given joint Id.
Index ngeoms
The number of GeometryObjects.
void addAllCollisionPairs()
Add all possible collision pairs.
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...
typedef PINOCCHIO_ALIGNED_STD_VECTOR(GeometryObject) GeometryObjectVector
Main pinocchio namespace.
Definition: timings.cpp:30
GeomIndex getGeometryId(const std::string &name) const
Return the index of a GeometryObject given by its name.
void addCollisionPair(const CollisionPair &pair)
Add a collision pair into the vector of collision_pairs. The method check before if the given Collisi...
std::size_t Index
std::vector< CollisionPair > CollisionPairVector
void removeAllCollisionPairs()
Remove all collision pairs from collisionPairs. Same as collisionPairs.clear().
friend std::ostream & operator<<(std::ostream &os, const GeometryModel &model_geom)
::pinocchio::GeometryObject GeometryObject
JointCollectionTpl & model
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXs
GeomIndex addGeometryObject(const GeometryObject &object, const ModelTpl< S2, O2, _JointCollectionTpl > &model)
Add a geometry object to a GeometryModel and set its parent joint.
SE3Tpl< Scalar, Options > SE3


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:03