pinocchio  2.1.3
fcl.hpp
1 //
2 // Copyright (c) 2015-2016 CNRS
3 //
4 
5 #ifndef __pinocchio_fcl_hpp__
6 #define __pinocchio_fcl_hpp__
7 
8 #include "pinocchio/spatial/se3.hpp"
9 #include "pinocchio/multibody/fwd.hpp"
10 #include "pinocchio/container/aligned-vector.hpp"
11 
12 #ifdef PINOCCHIO_WITH_HPP_FCL
13 #include <hpp/fcl/collision_object.h>
14 #include <hpp/fcl/collision.h>
15 #include <hpp/fcl/distance.h>
16 #include <hpp/fcl/shape/geometric_shapes.h>
17 #include "pinocchio/spatial/fcl-pinocchio-conversions.hpp"
18 #endif
19 
20 #include <iostream>
21 #include <map>
22 #include <vector>
23 #include <utility>
24 #include <assert.h>
25 
26 #include <boost/foreach.hpp>
27 #include <boost/shared_ptr.hpp>
28 
29 namespace pinocchio
30 {
31  struct CollisionPair: public std::pair<GeomIndex, GeomIndex>
32  {
33 
34  typedef std::pair<GeomIndex, GeomIndex> Base;
35 
36  CollisionPair(const GeomIndex co1, const GeomIndex co2);
37  bool operator == (const CollisionPair& rhs) const;
38  void disp (std::ostream & os) const;
39  friend std::ostream & operator << (std::ostream & os,const CollisionPair & X);
40 
41  }; // struct CollisionPair
42 
43 #ifndef PINOCCHIO_WITH_HPP_FCL
44 
45  namespace fcl
46  {
47 
48  struct FakeCollisionGeometry
49  {
50  FakeCollisionGeometry(){};
51  };
52 
53  struct AABB
54  {
55  AABB(): min_(0), max_(1){};
56 
57  int min_;
58  int max_;
59  };
60  typedef FakeCollisionGeometry CollisionGeometry;
61 
62  }
63 
64 #else
65 
66  namespace fcl = hpp::fcl;
67 
68 #endif // PINOCCHIO_WITH_HPP_FCL
69 
70 enum GeometryType
71 {
72  VISUAL,
73  COLLISION
74 };
75 
77 {
78  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
79 
81  std::string name;
82 
88  FrameIndex parentFrame;
89 
91  JointIndex parentJoint;
92 
94  boost::shared_ptr<fcl::CollisionGeometry> fcl;
95 
98 
100  std::string meshPath;
101 
103  Eigen::Vector3d meshScale;
104 
107 
109  Eigen::Vector4d meshColor;
110 
112  std::string meshTexturePath;
113 
114  GeometryObject(const std::string & name, const FrameIndex parentF,
115  const JointIndex parentJ,
116  const boost::shared_ptr<fcl::CollisionGeometry> & collision,
117  const SE3 & placement, const std::string & meshPath = "",
118  const Eigen::Vector3d & meshScale = Eigen::Vector3d::Ones(),
119  const bool overrideMaterial = false,
120  const Eigen::Vector4d & meshColor = Eigen::Vector4d::Zero(),
121  const std::string & meshTexturePath = "")
122  : name(name)
123  , parentFrame(parentF)
124  , parentJoint(parentJ)
125  , fcl(collision)
126  , placement(placement)
127  , meshPath(meshPath)
128  , meshScale(meshScale)
129  , overrideMaterial(overrideMaterial)
130  , meshColor(meshColor)
131  , meshTexturePath(meshTexturePath)
132  {}
133 
134  GeometryObject & operator=(const GeometryObject & other)
135  {
136  name = other.name;
137  parentFrame = other.parentFrame;
138  parentJoint = other.parentJoint;
139  fcl = other.fcl;
140  placement = other.placement;
141  meshPath = other.meshPath;
142  meshScale = other.meshScale;
143  overrideMaterial = other.overrideMaterial;
144  meshColor = other.meshColor;
145  meshTexturePath = other.meshTexturePath;
146  return *this;
147  }
148 
149  friend std::ostream & operator<< (std::ostream & os, const GeometryObject & geomObject);
150 };
151 
152 
153 } // namespace pinocchio
154 
155 /* --- Details -------------------------------------------------------------- */
156 /* --- Details -------------------------------------------------------------- */
157 /* --- Details -------------------------------------------------------------- */
158 #include "pinocchio/multibody/fcl.hxx"
159 
160 
161 #endif // ifndef __pinocchio_fcl_hpp__
bool overrideMaterial
Decide whether to override the Material.
Definition: fcl.hpp:106
Eigen::Vector3d meshScale
Scaling vector applied to the fcl object.
Definition: fcl.hpp:103
std::string meshTexturePath
Absolute path to the mesh texture file.
Definition: fcl.hpp:112
JointIndex parentJoint
Index of the parent joint.
Definition: fcl.hpp:91
std::string name
Name of the geometry object.
Definition: fcl.hpp:81
std::string meshPath
Absolute path to the mesh file.
Definition: fcl.hpp:100
Main pinocchio namespace.
Definition: treeview.dox:24
SE3 placement
Position of geometry object in parent joint frame.
Definition: fcl.hpp:97
Eigen::Vector4d meshColor
RGBA color value of the mesh.
Definition: fcl.hpp:109
FrameIndex parentFrame
Index of the parent frame.
Definition: fcl.hpp:88
boost::shared_ptr< fcl::CollisionGeometry > fcl
The actual cloud of points representing the collision mesh of the object after scaling.
Definition: fcl.hpp:94