extract_polygon_primitives_rvizmarkers.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
36 #ifndef _extract_polygon_primitives_RVIZMARKERS_CPP_
37 #define _extract_polygon_primitives_RVIZMARKERS_CPP_
38 
43 
44 visualization_msgs::Marker create_visualization_marker_header(
45  std::string frame_id, ros::Time stamp, std::string name,
46  int action, int id, int type,
47  double px, double py, double pz,
48  double qx, double qy, double qz, double qw,
49  double sx, double sy, double sz,
50  double cr, double cg, double cb, double alpha
51  )
52 {
53  visualization_msgs::Marker mk;
54  mk.header.frame_id = frame_id; mk.header.stamp = stamp; mk.ns = name;
55  mk.action = action; mk.type = type; mk.id = id;
56  mk.pose.position.x = px; mk.pose.position.y = py; mk.pose.position.z = pz;
57  mk.pose.orientation.x = qx; mk.pose.orientation.y = qy; mk.pose.orientation.z = qz; mk.pose.orientation.w = qw;
58  mk.scale.x = sx; mk.scale.y = sy; mk.scale.z = sz;
59  mk.color.r = cr; mk.color.g = cg; mk.color.b = cb; mk.color.a = alpha;
60  return mk;
61 }
62 
63 void create_publish_marker_array(std::vector<c_polygon_primitive> *plg, visualization_msgs::MarkerArray *marker_array_msg)
64 {
65  //Create and publish the marker array
67  std_msgs::ColorRGBA color;
68  std::vector<visualization_msgs::Marker> marker_vec;
69 
70  //for (int i=0, id=0; i<(int)plg->size();i++)
71  for (int i=0, id=0; i<plg->size();i++)
72  {
73 
74 
75  (*plg)[i].create_vizualization_msgs(marker_array_msg, 0+100*i);
76  continue;
77 
78  //if (true) //Polygon name marker (TEXT_VIEW_FACING)
79  //{
80  //visualization_msgs::Marker msg = create_visualization_marker_header(
81  //(*plg)[i].data.frames.global_name, ros::Time::now(),"name",
82  //visualization_msgs::Marker::ADD, id++, visualization_msgs::Marker::TEXT_VIEW_FACING,
83  //(*plg)[i].data.frames.current.origin.x, (*plg)[i].data.frames.current.origin.y, (*plg)[i].data.frames.current.origin.z,
84  //0,0,0,1,
85  //1,1,0.6,
86  //(*plg)[i].data.misc.color.r/255., (*plg)[i].data.misc.color.g/255., (*plg)[i].data.misc.color.b/255., 1
87  //);
88 
89  //char str[1024];
90  //sprintf(str,"%s A=%3.2f S=%3.2f",(*plg)[i].data.misc.name, (*plg)[i].data.hulls.convex.area, (*plg)[i].data.hulls.convex.solidity);
91  //std::string tmp_str(str);
92  //msg.text = tmp_str;
93  //marker_vec.push_back(msg);
94  //}
95 
96 
97  //if (true) //concave hull marker (LINE_STRIP)
98  //{
99  //visualization_msgs::Marker msg = create_visualization_marker_header(
100  //(*plg)[i].data.frames.global_name, ros::Time::now(),"concave_hull",
101  //visualization_msgs::Marker::ADD, id++, visualization_msgs::Marker::LINE_STRIP,
102  //0,0,0,
103  //0,0,0,1,
104  //0.05,1,1,
106  //0, 1, 0,1
107  //);
108 
109  //if ((int)(*plg)[i].data.hulls.concave.polygon->points.size() >0)
110  //{
111  //for (unsigned int u=0; u< (*plg)[i].data.hulls.concave.polygon->size(); u++)
112  //{
113  //p.x = (*plg)[i].data.hulls.concave.polygon->points[u].x;
114  //p.y = (*plg)[i].data.hulls.concave.polygon->points[u].y;
115  //p.z = (*plg)[i].data.hulls.concave.polygon->points[u].z;
116  //msg.points.push_back(p);
117  //}
118  //p.x = (*plg)[i].data.hulls.concave.polygon->points[0].x;
119  //p.y = (*plg)[i].data.hulls.concave.polygon->points[0].y;
120  //p.z = (*plg)[i].data.hulls.concave.polygon->points[0].z;
121  //msg.points.push_back(p);
122  //}
123  //else
124  //{
125  //p.x = 0; p.y = 0; p.z = 0;
126  //msg.points.push_back(p);
127  //p.x = 1; p.y = 1; p.z = 1;
128  //msg.points.push_back(p);
129  //}
130 
131  //ROS_INFO("msg r=%f g=%f b=%f", msg.color.r, msg.color.g, msg.color.b);
132  //marker_vec.push_back(msg);
133  //}
134 
135 
136  //if ((int)(*plg)[i].data.hulls.convex.polygon->points.size() >1) //convex hull marker (LINE_STRIP)
137  //{
138  //visualization_msgs::Marker msg = create_visualization_marker_header(
139  //(*plg)[i].data.frames.global_name, ros::Time::now(),"convex_hull",
140  //visualization_msgs::Marker::ADD, id++, visualization_msgs::Marker::LINE_STRIP,
141  //0,0,0,
142  //0,0,0,1,
143  //0.05,1,1,
145  //1,0,0, 1
146  //);
147 
148  //for (unsigned int u=0; u< (*plg)[i].data.hulls.convex.polygon->size(); u++)
149  //{
150  //p.x = (*plg)[i].data.hulls.convex.polygon->points[u].x;
151  //p.y = (*plg)[i].data.hulls.convex.polygon->points[u].y;
152  //p.z = (*plg)[i].data.hulls.convex.polygon->points[u].z;
153  //msg.points.push_back(p);
154  //}
155  //p.x = (*plg)[i].data.hulls.convex.polygon->points[0].x;
156  //p.y = (*plg)[i].data.hulls.convex.polygon->points[0].y;
157  //p.z = (*plg)[i].data.hulls.convex.polygon->points[0].z;
158  //msg.points.push_back(p);
159 
160  //marker_vec.push_back(msg);
161  //}
162 
163  //if ((int)(*plg)[i].data.hulls.convex.extended_polygon->points.size() >1) //extended convex hull marker (LINE_STRIP)
164  //{
165  //visualization_msgs::Marker msg = create_visualization_marker_header(
166  //(*plg)[i].data.frames.global_name, ros::Time::now(),"extended_convex_hull",
167  //visualization_msgs::Marker::ADD, id++, visualization_msgs::Marker::LINE_STRIP,
168  //0,0,0,
169  //0,0,0,1,
170  //0.05,1,1,
171  //(*plg)[i].data.misc.color.r/255./4, (*plg)[i].data.misc.color.g/255./4, (*plg)[i].data.misc.color.b/255./4, 1
172  //);
173 
174  //for (unsigned int u=0; u< (*plg)[i].data.hulls.convex.extended_polygon->size(); u++)
175  //{
176  //p.x = (*plg)[i].data.hulls.convex.extended_polygon->points[u].x;
177  //p.y = (*plg)[i].data.hulls.convex.extended_polygon->points[u].y;
178  //p.z = (*plg)[i].data.hulls.convex.extended_polygon->points[u].z;
179  //msg.points.push_back(p);
180  //}
181  //p.x = (*plg)[i].data.hulls.convex.extended_polygon->points[0].x;
182  //p.y = (*plg)[i].data.hulls.convex.extended_polygon->points[0].y;
183  //p.z = (*plg)[i].data.hulls.convex.extended_polygon->points[0].z;
184  //msg.points.push_back(p);
185 
186  //marker_vec.push_back(msg);
187  //}
188 
189 
190 
191  //}
192 
193 
194 
195 
196 
197 
198  //Draw the camera projections
199 
200  //for (size_t j=0; j< (*plg)[i].cp.size(); j++)
201  //{
202  //visualization_msgs::Marker msg11; //declare the msg
203  //msg11.header.frame_id = (*plg)[i].data.frames.global_name;
204  //msg11.header.stamp = ros::Time::now();
205  //msg11.ns = "raw_projection";
206  //msg11.action = visualization_msgs::Marker::ADD;
207  //msg11.pose.orientation.w = 1.0;
208  //msg11.type = visualization_msgs::Marker::POINTS;
209  //msg11.id = id++;
210 
211  //msg11.scale.x = 1;
212  //msg11.scale.y = 1;
213  //msg11.color.r = (*plg)[i].data.misc.color.r/255.;
214  //msg11.color.g = (*plg)[i].data.misc.color.g/255.;
215  //msg11.color.b = (*plg)[i].data.misc.color.b/255.;
216  //msg11.color.a = 1;
217 
218  //for (size_t u=0; u< (*plg)[i].cp[j].vertex_projectable.points.size(); u++)
219  //{
220  //p.x = (*plg)[i].cp[j].vertex_projectable.points[u].x;
221  //p.y = (*plg)[i].cp[j].vertex_projectable.points[u].y;
222  //p.z = (*plg)[i].cp[j].vertex_projectable.points[u].z;
224 
225  //msg11.points.push_back(p);
226 
227  //uint32_t rgb = (uint32_t)(*plg)[i].cp[j].vertex_projectable.points[u].rgb;
228  //uint8_t r = (rgb >> 16) & 0x0000ff;
229  //uint8_t g = (rgb >> 8) & 0x0000ff;
230  //uint8_t b = (rgb) & 0x0000ff;
231 
232 
233  //color.r = (float)r/255.0;
234  //color.g = (float)g/255.0;
235  //color.b = (float)b/255.0;
236  //color.r = 1.0;
237  //color.g = 0.0;
238  //color.b = 0.0;
239  //color.a =1;
240 
241  //msg11.colors.push_back(color);
242 
243  //}
244 
245  //marker_vec.push_back(msg11);
246  //}
247  }
248 
249 // marker_array_msg->set_markers_vec(marker_vec);
250 }
251 
252 
253 
254 
255 #endif
256 
unsigned char cr[16]
void create_publish_marker_array(std::vector< c_polygon_primitive > *plg, visualization_msgs::MarkerArray *marker_array_msg)
visualization_msgs::Marker create_visualization_marker_header(std::string frame_id, ros::Time stamp, std::string name, int action, int id, int type, double px, double py, double pz, double qx, double qy, double qz, double qw, double sx, double sy, double sz, double cr, double cg, double cb, double alpha)
K::Point_2 Point
Definition: preh.h:66
Header of the extract polygon primitives binary.


polygon_primitives_extraction
Author(s): Miguel Oliveira
autogenerated on Mon Mar 2 2015 01:32:42