marker_shapes.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 MARKER_SHAPES_HPP_
19 #define MARKER_SHAPES_HPP_
20 
21 #include <ros/ros.h>
22 #include <visualization_msgs/Marker.h>
23 #include <shape_msgs/Mesh.h>
24 #include <shape_msgs/MeshTriangle.h>
25 
26 #include "fcl/shape/geometric_shapes.h"
27 #include "fcl/collision_object.h"
28 
31 
32 #include <fcl/distance.h>
33 #include <fcl/collision_data.h>
34 
35 static const std::string g_marker_namespace = "collision_object";
36 
37 /* BEGIN MarkerShape ********************************************************************************************/
39 template
40 <typename T>
41 class MarkerShape : public IMarkerShape
42 {
43  private:
45  std::shared_ptr<BVH_RSS_t> ptr_fcl_bvh_;
46 
47  void init(const std::string& root_frame, double x, double y, double z,
48  double quat_x, double quat_y, double quat_z, double quat_w,
49  double color_r, double color_g, double color_b, double color_a);
50 
51  public:
52  MarkerShape(const std::string& root_frame, T& fcl_object, const geometry_msgs::Pose& pose, const std_msgs::ColorRGBA& col)
53  : MarkerShape(root_frame, fcl_object,
54  pose.position.x, pose.position.y, pose.position.z,
55  pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w,
56  col.r, col.g, col.b, col.a)
57  {
58  }
59 
60  MarkerShape(const std::string& root_frame, T& fcl_object, const geometry_msgs::Point& pos, const geometry_msgs::Quaternion& quat, const std_msgs::ColorRGBA& col)
61  : MarkerShape(root_frame, fcl_object, pos.x, pos.y, pos.z, quat.x, quat.y, quat.z, quat.w, col.r, col.g, col.b, col.a)
62  {
63  }
64 
65  MarkerShape(const std::string& root_frame, T& fcl_object,
66  double x, double y, double z,
67  double quat_x = 0.0, double quat_y = 0.0, double quat_z = 0.0, double quat_w = 1.0,
68  double color_r = 0.0, double color_g = 0.0, double color_b = 0.0, double color_a = 1.0);
69 
70  MarkerShape(const std::string& root_frame, double x, double y, double z,
71  double quat_x = 0.0, double quat_y = 0.0, double quat_z = 0.0, double quat_w = 1.0,
72  double color_r = 0.0, double color_g = 0.0, double color_b = 0.0, double color_a = 1.0);
73 
74  inline geometry_msgs::Pose getMarkerPose() const;
75 
76  inline geometry_msgs::Pose getOriginRelToFrame() const;
77 
81  inline uint32_t getId() const;
82 
83  inline void setColor(double color_r, double color_g, double color_b, double color_a = 1.0);
84 
88  inline visualization_msgs::Marker getMarker();
89 
90  inline void updatePose(const geometry_msgs::Vector3& pos, const geometry_msgs::Quaternion& quat);
91 
92  inline void updatePose(const geometry_msgs::Pose& pose);
93 
97  fcl::CollisionObject getCollisionObject() const;
98 
99  virtual ~MarkerShape(){}
100 };
101 /* END MarkerShape **********************************************************************************************/
102 
103 
104 
105 /* BEGIN MarkerShape ********************************************************************************************/
106 template <>
108 {
109  private:
110  std::shared_ptr<BVH_RSS_t> ptr_fcl_bvh_;
111 
112  void init(const std::string& root_frame, const std::string& mesh_resource, double x, double y, double z,
113  double quat_x, double quat_y, double quat_z, double quat_w,
114  double color_r, double color_g, double color_b, double color_a);
115 
116  public:
117  MarkerShape(const std::string& root_frame, const shape_msgs::Mesh& mesh, const geometry_msgs::Pose& pose, const std_msgs::ColorRGBA& col);
118 
119  MarkerShape(const std::string& root_frame, const std::string& mesh_resource, const geometry_msgs::Pose& pose, const std_msgs::ColorRGBA& col)
120  : MarkerShape(root_frame, mesh_resource,
121  pose.position.x, pose.position.y, pose.position.z,
122  pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w,
123  col.r, col.g, col.b, col.a)
124  {
125  }
126 
127  MarkerShape(const std::string& root_frame, const std::string& mesh_resource, const geometry_msgs::Point& pos, const geometry_msgs::Quaternion& quat, const std_msgs::ColorRGBA& col)
128  : MarkerShape(root_frame, mesh_resource, pos.x, pos.y, pos.z, quat.x, quat.y, quat.z, quat.w, col.r, col.g, col.b, col.a)
129  {
130  }
131 
132  MarkerShape(const std::string& root_frame, const std::string& mesh_resource,
133  double x, double y, double z,
134  double quat_x = 0.0, double quat_y = 0.0, double quat_z = 0.0, double quat_w = 1.0,
135  double color_r = 0.0, double color_g = 0.0, double color_b = 0.0, double color_a = 1.0);
136 
137  inline geometry_msgs::Pose getMarkerPose() const;
138 
139  inline geometry_msgs::Pose getOriginRelToFrame() const;
140 
144  inline uint32_t getId() const;
145 
146  inline void setColor(double color_r, double color_g, double color_b, double color_a = 1.0);
147 
151  inline visualization_msgs::Marker getMarker();
152 
153  inline void updatePose(const geometry_msgs::Vector3& pos, const geometry_msgs::Quaternion& quat);
154 
155  inline void updatePose(const geometry_msgs::Pose& pose);
156 
160  fcl::CollisionObject getCollisionObject() const;
161 
162  virtual ~MarkerShape(){}
163 };
164 /* END MarkerShape **********************************************************************************************/
165 
166 
167 
168 
170 
171 #endif /* MARKER_SHAPES_HPP_ */
geometry_msgs::Pose getMarkerPose() const
void init(const std::string &root_frame, double x, double y, double z, double quat_x, double quat_y, double quat_z, double quat_w, double color_r, double color_g, double color_b, double color_a)
Template class implementation for box, sphere and cylinder fcl::shapes. Creates visualization marker...
FclMarkerConverter< T > fcl_marker_converter_
fcl::BVHModel< fcl::RSS > BVH_RSS_t
void updatePose(const geometry_msgs::Vector3 &pos, const geometry_msgs::Quaternion &quat)
visualization_msgs::Marker getMarker()
MarkerShape(const std::string &root_frame, T &fcl_object, const geometry_msgs::Point &pos, const geometry_msgs::Quaternion &quat, const std_msgs::ColorRGBA &col)
MarkerShape(const std::string &root_frame, const std::string &mesh_resource, const geometry_msgs::Pose &pose, const std_msgs::ColorRGBA &col)
static const std::string g_marker_namespace
std::shared_ptr< BVH_RSS_t > ptr_fcl_bvh_
virtual ~MarkerShape()
MarkerShape(const std::string &root_frame, const std::string &mesh_resource, const geometry_msgs::Point &pos, const geometry_msgs::Quaternion &quat, const std_msgs::ColorRGBA &col)
void setColor(double color_r, double color_g, double color_b, double color_a=1.0)
fcl::CollisionObject getCollisionObject() const
MarkerShape(const std::string &root_frame, T &fcl_object, const geometry_msgs::Pose &pose, const std_msgs::ColorRGBA &col)
geometry_msgs::Pose getOriginRelToFrame() const
r
Interface class marking methods that have to be implemented in derived classes.
std::shared_ptr< BVH_RSS_t > ptr_fcl_bvh_
uint32_t getId() const


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