Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef FCL_MARKER_CONVERTER_HPP_
00019 #define FCL_MARKER_CONVERTER_HPP_
00020
00021 #include <boost/scoped_ptr.hpp>
00022 #include <fcl/shape/geometric_shapes.h>
00023 #include <fcl/BVH/BVH_model.h>
00024 #include <fcl/shape/geometric_shape_to_BVH_model.h>
00025
00026
00027 #include "cob_obstacle_distance/marker_shapes/marker_shapes_interface.hpp"
00028
00029
00030
00031
00032 #define SEGMENTS 10u
00033 #define RINGS 10u
00034 #define SEG_AXIS 10u
00035 #define SEG_CIRCLE 10u
00036
00037 template <typename T>
00038 class FclMarkerConverter
00039 {
00040 private:
00041 FclMarkerConverter() {}
00042 FclMarkerConverter(T &t) {}
00043 };
00044
00045 template<>
00046 class FclMarkerConverter<fcl::Box>
00047 {
00048 typedef boost::scoped_ptr<fcl::Box> sPtrBox;
00049
00050 private:
00051 fcl::Box geo_shape_;
00052
00053 public:
00054 FclMarkerConverter() : geo_shape_(fcl::Box(1.0, 1.0, 1.0)) {}
00055 FclMarkerConverter(fcl::Box& box) : geo_shape_(box) {}
00056
00057 void assignValues(visualization_msgs::Marker& marker)
00058 {
00059 marker.scale.x = this->geo_shape_.side[0];
00060 marker.scale.y = this->geo_shape_.side[1];
00061 marker.scale.z = this->geo_shape_.side[2];
00062 marker.type = visualization_msgs::Marker::CUBE;
00063 }
00064
00065 fcl::Box getGeoShape() const
00066 {
00067 return geo_shape_;
00068 }
00069
00070 void getBvhModel(BVH_RSS_t& bvh) const
00071 {
00072 const fcl::Transform3f x;
00073 fcl::generateBVHModel(bvh, geo_shape_, x);
00074 }
00075 };
00076
00077 template<>
00078 class FclMarkerConverter<fcl::Sphere>
00079 {
00080 typedef boost::scoped_ptr<fcl::Sphere> sPtrSphere;
00081
00082 private:
00083 fcl::Sphere geo_shape_;
00084
00085 public:
00086 FclMarkerConverter() : geo_shape_(fcl::Sphere(1.0)) {}
00087 FclMarkerConverter(fcl::Sphere &sphere) : geo_shape_(sphere) {}
00088
00089 void assignValues(visualization_msgs::Marker &marker)
00090 {
00091 marker.scale.x = this->geo_shape_.radius * 2.0;
00092 marker.scale.y = this->geo_shape_.radius * 2.0;
00093 marker.scale.z = this->geo_shape_.radius * 2.0;
00094 marker.type = visualization_msgs::Marker::SPHERE;
00095 }
00096
00097 fcl::Sphere getGeoShape() const
00098 {
00099 return geo_shape_;
00100 }
00101
00108 void getBvhModel(BVH_RSS_t& bvh) const
00109 {
00110 const fcl::Transform3f x;
00111 fcl::generateBVHModel(bvh, geo_shape_, x, SEGMENTS, RINGS);
00112 }
00113 };
00114
00115 template<>
00116 class FclMarkerConverter<fcl::Cylinder>
00117 {
00118 typedef boost::scoped_ptr<fcl::Cylinder> sPtrCylinder;
00119
00120 private:
00121 fcl::Cylinder geo_shape_;
00122
00123 public:
00124 FclMarkerConverter() : geo_shape_(fcl::Cylinder(1.0, 1.0)) {}
00125 FclMarkerConverter(fcl::Cylinder &cyl) : geo_shape_(cyl) {}
00126
00127 void assignValues(visualization_msgs::Marker &marker)
00128 {
00129 marker.scale.x = this->geo_shape_.radius * 2.0;
00130 marker.scale.y = this->geo_shape_.radius * 2.0;
00131 marker.scale.z = this->geo_shape_.lz;
00132 marker.type = visualization_msgs::Marker::CYLINDER;
00133 }
00134
00135 fcl::Cylinder getGeoShape() const
00136 {
00137 return geo_shape_;
00138 }
00139
00140 void getBvhModel(BVH_RSS_t& bvh) const
00141 {
00142 const fcl::Transform3f x;
00143 fcl::generateBVHModel(bvh, geo_shape_, x, SEG_CIRCLE, SEG_AXIS);
00144 }
00145 };
00146
00147 #endif