fcl_marker_converter.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef FCL_MARKER_CONVERTER_HPP_
19 #define FCL_MARKER_CONVERTER_HPP_
20 
21 #include <boost/scoped_ptr.hpp>
22 #include <fcl/shape/geometric_shapes.h>
23 #include <fcl/BVH/BVH_model.h>
24 #include <fcl/shape/geometric_shape_to_BVH_model.h>
25 
26 
28 
29 // the less the better performance for BVH generation and distance calculation
30 // E.g. values == 100u then CPU% at 20 Hz is 65 %
31 // E.g. values == 10u then CPU% at 20 Hz is 35 %
32 #define SEGMENTS 10u
33 #define RINGS 10u
34 #define SEG_AXIS 10u
35 #define SEG_CIRCLE 10u
36 
37 template <typename T>
39 {
40  private:
43 };
44 
45 template<>
46 class FclMarkerConverter<fcl::Box>
47 {
48  typedef boost::scoped_ptr<fcl::Box> sPtrBox;
49 
50  private:
51  fcl::Box geo_shape_;
52 
53  public:
54  FclMarkerConverter() : geo_shape_(fcl::Box(1.0, 1.0, 1.0)) {}
55  FclMarkerConverter(fcl::Box& box) : geo_shape_(box) {}
56 
57  void assignValues(visualization_msgs::Marker& marker)
58  {
59  marker.scale.x = this->geo_shape_.side[0];
60  marker.scale.y = this->geo_shape_.side[1];
61  marker.scale.z = this->geo_shape_.side[2];
62  marker.type = visualization_msgs::Marker::CUBE;
63  }
64 
65  fcl::Box getGeoShape() const
66  {
67  return geo_shape_;
68  }
69 
70  void getBvhModel(BVH_RSS_t& bvh) const
71  {
72  const fcl::Transform3f x;
73  fcl::generateBVHModel(bvh, geo_shape_, x);
74  }
75 };
76 
77 template<>
78 class FclMarkerConverter<fcl::Sphere>
79 {
80  typedef boost::scoped_ptr<fcl::Sphere> sPtrSphere;
81 
82  private:
83  fcl::Sphere geo_shape_;
84 
85  public:
86  FclMarkerConverter() : geo_shape_(fcl::Sphere(1.0)) {}
87  FclMarkerConverter(fcl::Sphere &sphere) : geo_shape_(sphere) {}
88 
89  void assignValues(visualization_msgs::Marker &marker)
90  {
91  marker.scale.x = this->geo_shape_.radius * 2.0; // marker needs the diameter in x
92  marker.scale.y = this->geo_shape_.radius * 2.0; // marker needs the diameter in y
93  marker.scale.z = this->geo_shape_.radius * 2.0; // marker needs the diameter in z
94  marker.type = visualization_msgs::Marker::SPHERE;
95  }
96 
97  fcl::Sphere getGeoShape() const
98  {
99  return geo_shape_;
100  }
101 
108  void getBvhModel(BVH_RSS_t& bvh) const
109  {
110  const fcl::Transform3f x;
111  fcl::generateBVHModel(bvh, geo_shape_, x, SEGMENTS, RINGS);
112  }
113 };
114 
115 template<>
116 class FclMarkerConverter<fcl::Cylinder>
117 {
118  typedef boost::scoped_ptr<fcl::Cylinder> sPtrCylinder;
119 
120  private:
121  fcl::Cylinder geo_shape_;
122 
123  public:
124  FclMarkerConverter() : geo_shape_(fcl::Cylinder(1.0, 1.0)) {}
125  FclMarkerConverter(fcl::Cylinder &cyl) : geo_shape_(cyl) {}
126 
127  void assignValues(visualization_msgs::Marker &marker)
128  {
129  marker.scale.x = this->geo_shape_.radius * 2.0; // marker needs the diameter in x
130  marker.scale.y = this->geo_shape_.radius * 2.0; // marker needs the diameter in y
131  marker.scale.z = this->geo_shape_.lz;
132  marker.type = visualization_msgs::Marker::CYLINDER;
133  }
134 
135  fcl::Cylinder getGeoShape() const
136  {
137  return geo_shape_;
138  }
139 
140  void getBvhModel(BVH_RSS_t& bvh) const
141  {
142  const fcl::Transform3f x;
143  fcl::generateBVHModel(bvh, geo_shape_, x, SEG_CIRCLE, SEG_AXIS);
144  }
145 };
146 
147 #endif /* FCL_MARKER_CONVERTER_HPP_ */
boost::scoped_ptr< fcl::Box > sPtrBox
void getBvhModel(BVH_RSS_t &bvh) const
#define RINGS
void getBvhModel(BVH_RSS_t &bvh) const
fcl::BVHModel< fcl::RSS > BVH_RSS_t
void getBvhModel(BVH_RSS_t &bvh) const
void assignValues(visualization_msgs::Marker &marker)
#define SEG_AXIS
void assignValues(visualization_msgs::Marker &marker)
boost::scoped_ptr< fcl::Sphere > sPtrSphere
boost::scoped_ptr< fcl::Cylinder > sPtrCylinder
#define SEG_CIRCLE
void assignValues(visualization_msgs::Marker &marker)
#define SEGMENTS


cob_obstacle_distance
Author(s): Marco Bezzon
autogenerated on Thu Apr 8 2021 02:39:47