pinocchio  2.1.3
multibody/geometry.hpp
1 //
2 // Copyright (c) 2015-2018 CNRS
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/model.hpp"
10 #include "pinocchio/container/aligned-vector.hpp"
11 
12 #include <iostream>
13 
14 #include <boost/foreach.hpp>
15 #include <map>
16 #include <list>
17 #include <utility>
18 #include <assert.h>
19 
20 namespace pinocchio
21 {
22 
24  {
25  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 
27  typedef double Scalar;
28  enum { Options = 0 };
29 
31 
33  typedef std::vector<CollisionPair> CollisionPairVector;
34 
35  typedef pinocchio::GeomIndex GeomIndex;
36 
38  Index ngeoms;
39 
41  GeometryObjectVector geometryObjects;
45  CollisionPairVector collisionPairs;
46 
48  : ngeoms(0)
49  , geometryObjects()
50  , collisionPairs()
51  {
52  const std::size_t num_max_collision_pairs = (ngeoms * (ngeoms-1))/2;
53  collisionPairs.reserve(num_max_collision_pairs);
54  }
55 
56  ~GeometryModel() {};
57 
69  template<typename S2, int O2, template<typename,int> class _JointCollectionTpl>
70  PINOCCHIO_DEPRECATED
73  const bool autofillJointParent)
74  {
75  if(autofillJointParent)
76  return addGeometryObject(object,model);
77  else
78  return addGeometryObject(object);
79  }
80 
90  template<typename S2, int O2, template<typename,int> class _JointCollectionTpl>
91  GeomIndex addGeometryObject(const GeometryObject & object,
93 
101  GeomIndex addGeometryObject(const GeometryObject & object);
102 
110  GeomIndex getGeometryId(const std::string & name) const;
111 
112 
120  bool existGeometryName(const std::string & name) const;
121 
122 
130  PINOCCHIO_DEPRECATED const std::string & getGeometryName(const GeomIndex index) const;
131 
132 #ifdef PINOCCHIO_WITH_HPP_FCL
133  void addCollisionPair(const CollisionPair & pair);
140 
147  void addAllCollisionPairs();
148 
154  void removeCollisionPair(const CollisionPair& pair);
155 
158  void removeAllCollisionPairs ();
159 
168  bool existCollisionPair(const CollisionPair & pair) const;
169 
177  PairIndex findCollisionPair(const CollisionPair & pair) const;
178 
179 #endif // PINOCCHIO_WITH_HPP_FCL
180 
181  friend std::ostream& operator<<(std::ostream & os, const GeometryModel & model_geom);
182  }; // struct GeometryModel
183 
185  {
186  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
187 
188  typedef double Scalar;
189  enum { Options = 0 };
190 
191  typedef SE3Tpl<Scalar,Options> SE3;
192 
201 
202 #ifdef PINOCCHIO_WITH_HPP_FCL
203  std::vector<fcl::CollisionObject> collisionObjects;
210 
214  std::vector<bool> activeCollisionPairs;
215 
219  fcl::DistanceRequest distanceRequest;
220 
224  std::vector<fcl::DistanceResult> distanceResults;
225 
229  fcl::CollisionRequest collisionRequest;
230 
234  std::vector<fcl::CollisionResult> collisionResults;
235 
240  std::vector<double> radius;
241 
249 
250  typedef std::vector<GeomIndex> GeomIndexList;
251 
256  std::map < JointIndex, GeomIndexList > innerObjects;
257 
262  std::map < JointIndex, GeomIndexList > outerObjects;
263 #endif // PINOCCHIO_WITH_HPP_FCL
264 
265  GeometryData(const GeometryModel & geomModel);
266  ~GeometryData() {};
267 
268 #ifdef PINOCCHIO_WITH_HPP_FCL
269 
279  void fillInnerOuterObjectMaps(const GeometryModel & geomModel);
280 
290  PINOCCHIO_DEPRECATED
291  void activateCollisionPair(const PairIndex pairId, const bool flag);
292 
306  void activateCollisionPair(const PairIndex pairId);
307 
317  void deactivateCollisionPair(const PairIndex pairId);
318 
319 #endif //PINOCCHIO_WITH_HPP_FCL
320  friend std::ostream & operator<<(std::ostream & os, const GeometryData & geomData);
321 
322  }; // struct GeometryData
323 
324 } // namespace pinocchio
325 
326 /* --- Details -------------------------------------------------------------- */
327 /* --- Details -------------------------------------------------------------- */
328 /* --- Details -------------------------------------------------------------- */
329 #include "pinocchio/multibody/geometry.hxx"
330 
331 #endif // ifndef __pinocchio_multibody_geometry_hpp__
bool existGeometryName(const std::string &name) const
Check if a GeometryObject given by its name exists.
container::aligned_vector< SE3 > oMg
Vector gathering the SE3 placements of the geometry objects relative to the world. See updateGeometryPlacements to update the placements.
CollisionPairVector collisionPairs
Vector of collision pairs.
std::map< JointIndex, GeomIndexList > outerObjects
A list of associated collision GeometryObjects to a given joint Id.
GeomIndex getGeometryId(const std::string &name) const
Return the index of a GeometryObject given by its name.
std::vector< fcl::DistanceResult > distanceResults
Vector gathering the result of the distance computation for all the collision pairs.
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
std::vector< fcl::CollisionResult > collisionResults
Vector gathering the result of the collision computation for all the collision pairs.
void removeAllCollisionPairs()
Remove all collision pairs from collisionPairs. Same as collisionPairs.clear().
std::vector< double > radius
Radius of the bodies, i.e. distance of the further point of the geometry model attached to the body f...
void removeCollisionPair(const CollisionPair &pair)
Remove if exists the CollisionPair from the vector collision_pairs.
fcl::DistanceRequest distanceRequest
Defines what information should be computed by distance computation.
PINOCCHIO_DEPRECATED const std::string & getGeometryName(const GeomIndex index) const
Get the name of a GeometryObject given by its index.
Index ngeoms
The number of GeometryObjects.
std::vector< bool > activeCollisionPairs
Vector of collision pairs.
void addAllCollisionPairs()
Add all possible collision pairs.
PINOCCHIO_DEPRECATED GeomIndex addGeometryObject(GeometryObject object, const ModelTpl< S2, O2, _JointCollectionTpl > &model, const bool autofillJointParent)
Add a geometry object to a GeometryModel.
Main pinocchio namespace.
Definition: treeview.dox:24
fcl::CollisionRequest collisionRequest
Defines what information should be computed by collision test.
std::map< JointIndex, GeomIndexList > innerObjects
Map over vector GeomModel::geometryObjects, indexed by joints.
PairIndex collisionPairIndex
index of the collision pair
PairIndex findCollisionPair(const CollisionPair &pair) const
Return the index of a given collision pair in collisionPairs.
bool existCollisionPair(const CollisionPair &pair) const
Check if a collision pair exists in collisionPairs. See also findCollisitionPair(const CollisionPair ...
void addCollisionPair(const CollisionPair &pair)
Add a collision pair into the vector of collision_pairs. The method check before if the given Collisi...
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.