pinocchio  UNKNOWN
fcl.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_fcl_hpp__
19 #define __se3_fcl_hpp__
20 
21 #include "pinocchio/spatial/se3.hpp"
22 #include "pinocchio/multibody/fwd.hpp"
23 #include "pinocchio/container/aligned-vector.hpp"
24 
25 #ifdef WITH_HPP_FCL
26 #include <hpp/fcl/collision_object.h>
27 #include <hpp/fcl/collision.h>
28 #include <hpp/fcl/distance.h>
29 #include <hpp/fcl/shape/geometric_shapes.h>
30 #include "pinocchio/spatial/fcl-pinocchio-conversions.hpp"
31 #endif
32 
33 #include <iostream>
34 #include <map>
35 #include <vector>
36 #include <utility>
37 #include <assert.h>
38 
39 #include <boost/foreach.hpp>
40 #include <boost/shared_ptr.hpp>
41 
42 namespace se3
43 {
44  struct CollisionPair: public std::pair<GeomIndex, GeomIndex>
45  {
46 
47  typedef std::pair<GeomIndex, GeomIndex> Base;
48 
49  CollisionPair(const GeomIndex co1, const GeomIndex co2);
50  bool operator == (const CollisionPair& rhs) const;
51  void disp (std::ostream & os) const;
52  friend std::ostream & operator << (std::ostream & os,const CollisionPair & X);
53 
54  }; // struct CollisionPair
55 
56  typedef std::vector<CollisionPair> CollisionPairsVector_t;
57 
58 #ifndef WITH_HPP_FCL
59 
60  namespace fcl
61  {
62 
63  struct FakeCollisionGeometry
64  {
65  FakeCollisionGeometry(){};
66  };
67 
68  struct AABB
69  {
70  AABB(): min_(0), max_(1){};
71 
72  int min_;
73  int max_;
74  };
75  typedef FakeCollisionGeometry CollisionGeometry;
76 
77  }
78 
79 #endif // WITH_HPP_FCL
80 
81 enum GeometryType
82 {
83  VISUAL,
84  COLLISION
85 };
86 
88 {
89  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
90 
92  std::string name;
93 
99  FrameIndex parentFrame;
100 
102  JointIndex parentJoint;
103 
105  boost::shared_ptr<fcl::CollisionGeometry> fcl;
106 
109 
111  std::string meshPath;
112 
114  Eigen::Vector3d meshScale;
115 
118 
120  Eigen::Vector4d meshColor;
121 
123  std::string meshTexturePath;
124 
125 
126 
127  GeometryObject(const std::string & name, const FrameIndex parentF,
128  const JointIndex parentJ,
129  const boost::shared_ptr<fcl::CollisionGeometry> & collision,
130  const SE3 & placement, const std::string & meshPath = "",
131  const Eigen::Vector3d & meshScale = Eigen::Vector3d::Ones(),
132  const bool overrideMaterial = false,
133  const Eigen::Vector4d & meshColor = Eigen::Vector4d::Zero(),
134  const std::string & meshTexturePath = "")
135  : name(name)
136  , parentFrame(parentF)
137  , parentJoint(parentJ)
138  , fcl(collision)
139  , placement(placement)
140  , meshPath(meshPath)
141  , meshScale(meshScale)
142  , overrideMaterial(overrideMaterial)
143  , meshColor(meshColor)
144  , meshTexturePath(meshTexturePath)
145  {}
146 
147  GeometryObject & operator=(const GeometryObject & other)
148  {
149  name = other.name;
150  parentFrame = other.parentFrame;
151  parentJoint = other.parentJoint;
152  fcl = other.fcl;
153  placement = other.placement;
154  meshPath = other.meshPath;
155  meshScale = other.meshScale;
156  overrideMaterial = other.overrideMaterial;
157  meshColor = other.meshColor;
158  meshTexturePath = other.meshTexturePath;
159  return *this;
160  }
161 
162  friend std::ostream & operator<< (std::ostream & os, const GeometryObject & geomObject);
163 };
164 
165 
166 } // namespace se3
167 
168 /* --- Details -------------------------------------------------------------- */
169 /* --- Details -------------------------------------------------------------- */
170 /* --- Details -------------------------------------------------------------- */
171 #include "pinocchio/multibody/fcl.hxx"
172 
173 
174 #endif // ifndef __se3_fcl_hpp__
JointIndex parentJoint
Index of the parent joint.
Definition: fcl.hpp:102
Eigen::Vector3d meshScale
Scaling vector applied to the fcl object.
Definition: fcl.hpp:114
boost::shared_ptr< fcl::CollisionGeometry > fcl
The actual cloud of points representing the collision mesh of the object after scaling.
Definition: fcl.hpp:105
CollisionPair(const GeomIndex co1, const GeomIndex co2)
Default constructor of a collision pair from two collision object indexes. The indexes must be ordere...
Definition: fcl.hxx:35
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::string name
Name of the geometry object.
Definition: fcl.hpp:92
std::string meshPath
Absolute path to the mesh file.
Definition: fcl.hpp:111
Eigen::Vector4d meshColor
RGBA color value of the mesh.
Definition: fcl.hpp:120
SE3 placement
Position of geometry object in parent joint frame.
Definition: fcl.hpp:108
std::string meshTexturePath
Absolute path to the mesh texture file.
Definition: fcl.hpp:123
FrameIndex parentFrame
Index of the parent frame.
Definition: fcl.hpp:99
bool overrideMaterial
Decide whether to override the Material.
Definition: fcl.hpp:117