pinocchio  UNKNOWN
multibody/geometry.hpp
1 //
2 // Copyright (c) 2015-2016 CNRS
3 //
4 // This file is part of Pinocchio
5 // Pinocchio is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // Pinocchio is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // Pinocchio If not, see
16 // <http://www.gnu.org/licenses/>.
17 
18 #ifndef __se3_geom_hpp__
19 #define __se3_geom_hpp__
20 
21 
22 #include "pinocchio/multibody/fcl.hpp"
23 #include "pinocchio/multibody/model.hpp"
24 #include "pinocchio/container/aligned-vector.hpp"
25 
26 #include <iostream>
27 
28 #include <boost/foreach.hpp>
29 #include <map>
30 #include <list>
31 #include <utility>
32 #include <assert.h>
33 
34 
35 namespace se3
36 {
37 
39  {
40  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
41 
43  Index ngeoms;
44 
50  std::vector<CollisionPair> collisionPairs;
51 
53  : ngeoms(0)
54  , geometryObjects()
55  , collisionPairs()
56  {
57  const std::size_t num_max_collision_pairs = (ngeoms * (ngeoms-1))/2;
58  collisionPairs.reserve(num_max_collision_pairs);
59  }
60 
61  ~GeometryModel() {};
62 
73  inline GeomIndex addGeometryObject(GeometryObject object,
74  const Model & model,
75  const bool autofillJointParent = false);
76 
84  GeomIndex getGeometryId(const std::string & name) const;
85 
86 
94  bool existGeometryName(const std::string & name) const;
95 
96 
104  PINOCCHIO_DEPRECATED const std::string & getGeometryName(const GeomIndex index) const;
105 
106 #ifdef WITH_HPP_FCL
107  void addCollisionPair (const CollisionPair & pair);
114 
121  void addAllCollisionPairs();
122 
128  void removeCollisionPair (const CollisionPair& pair);
129 
132  void removeAllCollisionPairs ();
133 
142  bool existCollisionPair (const CollisionPair & pair) const;
143 
151  PairIndex findCollisionPair (const CollisionPair & pair) const;
152 
153 #endif // WITH_HPP_FCL
154 
155  friend std::ostream& operator<<(std::ostream & os, const GeometryModel & model_geom);
156  }; // struct GeometryModel
157 
159  {
160  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
161 
170 
171 #ifdef WITH_HPP_FCL
172  std::vector<fcl::CollisionObject> collisionObjects;
179 
183  std::vector<bool> activeCollisionPairs;
184 
188  fcl::DistanceRequest distanceRequest;
189 
193  std::vector <fcl::DistanceResult> distanceResults;
194 
198  fcl::CollisionRequest collisionRequest;
199 
203  std::vector <fcl::CollisionResult> collisionResults;
204 
209  std::vector<double> radius;
210 
218 
219  typedef std::vector<GeomIndex> GeomIndexList;
220 
225  std::map < JointIndex, GeomIndexList > innerObjects;
226 
231  std::map < JointIndex, GeomIndexList > outerObjects;
232 #endif // WITH_HPP_FCL
233 
234  GeometryData(const GeometryModel & geomModel);
235  ~GeometryData() {};
236 
237 #ifdef WITH_HPP_FCL
238 
248  void fillInnerOuterObjectMaps(const GeometryModel & geomModel);
249 
259  void activateCollisionPair(const PairIndex pairId,const bool flag=true);
260 
265  void deactivateCollisionPair(const PairIndex pairId);
266 
267 #endif //WITH_HPP_FCL
268  friend std::ostream & operator<<(std::ostream & os, const GeometryData & geomData);
269 
270  }; // struct GeometryData
271 
272 } // namespace se3
273 
274 /* --- Details -------------------------------------------------------------- */
275 /* --- Details -------------------------------------------------------------- */
276 /* --- Details -------------------------------------------------------------- */
277 #include "pinocchio/multibody/geometry.hxx"
278 
279 #endif // ifndef __se3_geom_hpp__
container::aligned_vector< GeometryObject > geometryObjects
Vector of GeometryObjects used for collision computations.
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...
void removeAllCollisionPairs()
Remove all collision pairs from collisionPairs. Same as collisionPairs.clear().
std::vector< bool > activeCollisionPairs
Vector of collision pairs.
void addAllCollisionPairs()
Add all possible collision pairs.
PINOCCHIO_DEPRECATED const std::string & getGeometryName(const GeomIndex index) const
Get the name of a GeometryObject given by its index.
std::string name(const LieGroupVariant &lg)
Visit a LieGroupVariant to get the name of it.
fcl::CollisionRequest collisionRequest
Defines what information should be computed by collision test.
std::vector< fcl::CollisionResult > collisionResults
Vector gathering the result of the collision computation for all the collision pairs.
std::vector< CollisionPair > collisionPairs
Vector of collision pairs.
std::vector< fcl::DistanceResult > distanceResults
Vector gathering the result of the distance computation for all the collision pairs.
void removeCollisionPair(const CollisionPair &pair)
Remove if exists the CollisionPair from the vector collision_pairs.
std::map< JointIndex, GeomIndexList > innerObjects
Map over vector GeomModel::geometryObjects, indexed by joints.
fcl::DistanceRequest distanceRequest
Defines what information should be computed by distance computation.
PairIndex collisionPairIndex
index of the collision pair
bool existCollisionPair(const CollisionPair &pair) const
Check if a collision pair exists in collisionPairs. See also findCollisitionPair(const CollisionPair ...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Index ngeoms
The number of GeometryObjects.
std::vector< double > radius
Radius of the bodies, i.e. distance of the further point of the geometry model attached to the body f...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW container::aligned_vector< se3::SE3 > oMg
Vector gathering the SE3 placements of the geometry objects relative to the world. See updateGeometryPlacements to update the placements.
std::map< JointIndex, GeomIndexList > outerObjects
A list of associated collision GeometryObjects to a given joint Id.
GeomIndex addGeometryObject(GeometryObject object, const Model &model, const bool autofillJointParent=false)
Add a geometry object to a GeometryModel.
PairIndex findCollisionPair(const CollisionPair &pair) const
Return the index of a given collision pair in collisionPairs.
Specialization of an std::vector with an aligned allocator. This specialization might be used when th...
bool existGeometryName(const std::string &name) const
Check if a GeometryObject given by its name exists.