marker_shapes_impl.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_IMPL_HPP_
19 #define MARKER_SHAPES_IMPL_HPP_
20 
22 
23 /* BEGIN MarkerShape ********************************************************************************************/
24 template <typename T>
25 MarkerShape<T>::MarkerShape(const std::string& root_frame, T& fcl_object,
26  double x, double y, double z,
27  double quat_x, double quat_y, double quat_z, double quat_w,
28  double color_r, double color_g, double color_b, double color_a) : fcl_marker_converter_(fcl_object)
29 {
30  this->init(root_frame, x, y, z, quat_x, quat_y, quat_z, quat_w, color_r, color_g, color_b, color_a);
31 }
32 
33 
34 template <typename T>
35 MarkerShape<T>::MarkerShape(const std::string& root_frame, double x, double y, double z,
36  double quat_x, double quat_y, double quat_z, double quat_w,
37  double color_r, double color_g, double color_b, double color_a)
38 {
39  this->init(root_frame, x, y, z, quat_x, quat_y, quat_z, quat_w, color_r, color_g, color_b, color_a);
40 }
41 
42 template <typename T>
43 geometry_msgs::Pose MarkerShape<T>::getMarkerPose() const
44 {
45  return this->marker_.pose;
46 }
47 
48 
49 template <typename T>
50 geometry_msgs::Pose MarkerShape<T>::getOriginRelToFrame() const
51 {
52  return this->origin_;
53 }
54 
55 
56 template <typename T>
57 void MarkerShape<T>::init(const std::string& root_frame, double x, double y, double z,
58  double quat_x, double quat_y, double quat_z, double quat_w,
59  double color_r, double color_g, double color_b, double color_a)
60 {
61  marker_.pose.position.x = origin_.position.x = x;
62  marker_.pose.position.y = origin_.position.y = y;
63  marker_.pose.position.z = origin_.position.z = z;
64  marker_.pose.orientation.x = origin_.orientation.x = quat_x;
65  marker_.pose.orientation.y = origin_.orientation.y = quat_y;
66  marker_.pose.orientation.z = origin_.orientation.z = quat_z;
67  marker_.pose.orientation.w = origin_.orientation.w = quat_w;
68 
69  marker_.color.r = color_r;
70  marker_.color.g = color_g;
71  marker_.color.b = color_b;
72  marker_.color.a = color_a;
73 
74  marker_.header.frame_id = root_frame;
75  marker_.header.stamp = ros::Time::now();
77  marker_.action = visualization_msgs::Marker::ADD;
78  marker_.id = class_ctr_;
79 
80  marker_.lifetime = ros::Duration();
81 
82  fcl_marker_converter_.assignValues(marker_);
83 
84  BVH_RSS_t bvh;
85  fcl_marker_converter_.getBvhModel(bvh);
86  this->ptr_fcl_bvh_.reset(new BVH_RSS_t(bvh));
87  this->ptr_fcl_bvh_->computeLocalAABB();
88 }
89 
90 
91 template <typename T>
92 inline uint32_t MarkerShape<T>::getId() const
93 {
94  return this->marker_.id;
95 }
96 
97 
98 template <typename T>
99 inline void MarkerShape<T>::setColor(double color_r, double color_g, double color_b, double color_a)
100 {
101  marker_.color.r = color_r;
102  marker_.color.g = color_g;
103  marker_.color.b = color_b;
104  marker_.color.a = color_a;
105  fcl_marker_converter_.assignValues(marker_);
106 }
107 
108 
109 template <typename T>
110 inline visualization_msgs::Marker MarkerShape<T>::getMarker()
111 {
112  this->marker_.header.stamp = ros::Time::now();
113  return this->marker_;
114 }
115 
116 
117 template <typename T>
118 fcl::CollisionObject MarkerShape<T>::getCollisionObject() const
119 {
120  fcl::Transform3f x(fcl::Quaternion3f(this->marker_.pose.orientation.w,
121  this->marker_.pose.orientation.x,
122  this->marker_.pose.orientation.y,
123  this->marker_.pose.orientation.z),
124  fcl::Vec3f(this->marker_.pose.position.x,
125  this->marker_.pose.position.y,
126  this->marker_.pose.position.z));
127  fcl::CollisionObject cobj(this->ptr_fcl_bvh_, x);
128  return cobj;
129 }
130 
131 
132 template <typename T>
133 inline void MarkerShape<T>::updatePose(const geometry_msgs::Vector3& pos, const geometry_msgs::Quaternion& quat)
134 {
135  marker_.pose.position.x = pos.x;
136  marker_.pose.position.y = pos.y;
137  marker_.pose.position.z = pos.z;
138  marker_.pose.orientation = quat;
139 }
140 
141 
142 template <typename T>
143 inline void MarkerShape<T>::updatePose(const geometry_msgs::Pose& pose)
144 {
145  marker_.pose = pose;
146 }
147 
148 /* END MarkerShape **********************************************************************************************/
149 
150 #endif /* MARKER_SHAPES_IMPL_HPP_ */
visualization_msgs::Marker marker_
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)
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()
static const std::string g_marker_namespace
std::shared_ptr< BVH_RSS_t > ptr_fcl_bvh_
void setColor(double color_r, double color_g, double color_b, double color_a=1.0)
static uint32_t class_ctr_
geometry_msgs::Pose origin_
fcl::CollisionObject getCollisionObject() const
MarkerShape(const std::string &root_frame, T &fcl_object, const geometry_msgs::Pose &pose, const std_msgs::ColorRGBA &col)
static Time now()
geometry_msgs::Pose getOriginRelToFrame() const
uint32_t getId() const


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