70 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
71 0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00 ,
72 0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
73 0x00,0x00,0x14,0x14,0x3E,0x14,0x14,0x3E,0x14,0x14,0x00,0x00 ,
74 0x00,0x08,0x1C,0x32,0x30,0x1C,0x06,0x26,0x1C,0x08,0x08,0x00 ,
75 0x00,0x13,0x2B,0x2B,0x16,0x0C,0x1A,0x35,0x35,0x32,0x00,0x00 ,
76 0x00,0x1C,0x36,0x36,0x1C,0x1D,0x37,0x36,0x36,0x1B,0x00,0x00 ,
77 0x00,0x0C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
78 0x00,0x0C,0x18,0x30,0x30,0x30,0x30,0x30,0x18,0x0C,0x00,0x00 ,
79 0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x30,0x00,0x00 ,
80 0x00,0x00,0x00,0x36,0x1C,0x7F,0x1C,0x36,0x00,0x00,0x00,0x00 ,
81 0x00,0x00,0x00,0x00,0x0C,0x0C,0x3F,0x0C,0x0C,0x00,0x00,0x00 ,
82 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x0C,0x18 ,
83 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00 ,
84 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00 ,
85 0x00,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x00,0x00 ,
86 0x00,0x1E,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3C,0x00,0x00 ,
87 0x00,0x0C,0x1C,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x00,0x00 ,
88 0x00,0x1C,0x36,0x36,0x06,0x0C,0x0C,0x18,0x30,0x3E,0x00,0x00 ,
89 0x00,0x1C,0x36,0x06,0x06,0x1C,0x06,0x06,0x36,0x1C,0x00,0x00 ,
90 0x00,0x18,0x18,0x18,0x36,0x36,0x36,0x3F,0x06,0x06,0x00,0x00 ,
91 0x00,0x3E,0x30,0x30,0x30,0x3C,0x06,0x06,0x36,0x1C,0x00,0x00 ,
92 0x00,0x0C,0x18,0x18,0x30,0x3C,0x36,0x36,0x36,0x1C,0x00,0x00 ,
93 0x00,0x3E,0x06,0x06,0x0C,0x0C,0x0C,0x18,0x18,0x18,0x00,0x00 ,
94 0x00,0x1C,0x36,0x36,0x36,0x1C,0x36,0x36,0x36,0x1C,0x00,0x00 ,
95 0x00,0x1C,0x36,0x36,0x36,0x1E,0x0C,0x0C,0x18,0x30,0x00,0x00 ,
96 0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00 ,
97 0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x1C,0x1C,0x0C,0x18 ,
98 0x00,0x02,0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x02,0x00,0x00 ,
99 0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x00,0x00 ,
100 0x00,0x20,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x20,0x00,0x00 ,
101 0x00,0x1C,0x36,0x36,0x06,0x0C,0x18,0x00,0x18,0x18,0x00,0x00 ,
102 0x00,0x0E,0x19,0x33,0x35,0x35,0x35,0x32,0x18,0x0F,0x00,0x00 ,
103 0x00,0x08,0x1C,0x36,0x36,0x36,0x3E,0x36,0x36,0x36,0x00,0x00 ,
104 0x00,0x3C,0x36,0x36,0x36,0x3C,0x36,0x36,0x36,0x3C,0x00,0x00 ,
105 0x00,0x1C,0x36,0x36,0x30,0x30,0x30,0x36,0x36,0x1C,0x00,0x00 ,
106 0x00,0x3C,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3C,0x00,0x00 ,
107 0x00,0x3E,0x30,0x30,0x30,0x3C,0x30,0x30,0x30,0x3E,0x00,0x00 ,
108 0x00,0x3E,0x30,0x30,0x30,0x3C,0x30,0x30,0x30,0x30,0x00,0x00 ,
109 0x00,0x1C,0x36,0x30,0x30,0x36,0x36,0x36,0x36,0x1C,0x00,0x00 ,
110 0x00,0x36,0x36,0x36,0x36,0x3E,0x36,0x36,0x36,0x36,0x00,0x00 ,
111 0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00 ,
112 0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x1C,0x00,0x00 ,
113 0x00,0x36,0x36,0x36,0x3C,0x38,0x3C,0x36,0x36,0x36,0x00,0x00 ,
114 0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3E,0x00,0x00 ,
115 0x00,0x63,0x63,0x77,0x77,0x7F,0x6B,0x6B,0x63,0x63,0x00,0x00 ,
116 0x00,0x33,0x33,0x3B,0x3B,0x3F,0x37,0x33,0x33,0x33,0x00,0x00 ,
117 0x00,0x1C,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x1C,0x00,0x00 ,
118 0x00,0x3C,0x36,0x36,0x36,0x3C,0x30,0x30,0x30,0x30,0x00,0x00 ,
119 0x00,0x1C,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x1C,0x0C,0x06 ,
120 0x00,0x3C,0x36,0x36,0x36,0x3C,0x36,0x36,0x36,0x36,0x00,0x00 ,
121 0x00,0x1C,0x36,0x32,0x38,0x1C,0x0E,0x26,0x36,0x1C,0x00,0x00 ,
122 0x00,0x3F,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x00,0x00 ,
123 0x00,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x1C,0x00,0x00 ,
124 0x00,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x1C,0x08,0x00,0x00 ,
125 0x00,0x63,0x63,0x6B,0x6B,0x6B,0x6B,0x36,0x36,0x36,0x00,0x00 ,
126 0x00,0x36,0x36,0x36,0x1C,0x08,0x1C,0x36,0x36,0x36,0x00,0x00 ,
127 0x00,0x33,0x33,0x33,0x33,0x1E,0x0C,0x0C,0x0C,0x0C,0x00,0x00 ,
128 0x00,0x3E,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x3E,0x00,0x00 ,
129 0x00,0x1E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1E ,
130 0x00,0x30,0x30,0x18,0x18,0x0C,0x0C,0x06,0x06,0x03,0x00,0x00 ,
131 0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C ,
132 0x00,0x08,0x1C,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
133 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F ,
134 0x00,0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
135 0x00,0x00,0x00,0x00,0x1C,0x06,0x1E,0x36,0x36,0x1E,0x00,0x00 ,
136 0x00,0x30,0x30,0x30,0x3C,0x36,0x36,0x36,0x36,0x3C,0x00,0x00 ,
137 0x00,0x00,0x00,0x00,0x1C,0x36,0x30,0x30,0x36,0x1C,0x00,0x00 ,
138 0x00,0x06,0x06,0x06,0x1E,0x36,0x36,0x36,0x36,0x1E,0x00,0x00 ,
139 0x00,0x00,0x00,0x00,0x1C,0x36,0x3E,0x30,0x32,0x1C,0x00,0x00 ,
140 0x00,0x0E,0x18,0x18,0x3E,0x18,0x18,0x18,0x18,0x18,0x00,0x00 ,
141 0x00,0x00,0x00,0x00,0x1E,0x36,0x36,0x36,0x1E,0x06,0x26,0x1C ,
142 0x00,0x30,0x30,0x30,0x3C,0x36,0x36,0x36,0x36,0x36,0x00,0x00 ,
143 0x00,0x0C,0x00,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00 ,
144 0x00,0x0C,0x00,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x38 ,
145 0x00,0x30,0x30,0x30,0x36,0x3C,0x38,0x3C,0x36,0x36,0x00,0x00 ,
146 0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00 ,
147 0x00,0x00,0x00,0x00,0x76,0x7F,0x6B,0x6B,0x6B,0x63,0x00,0x00 ,
148 0x00,0x00,0x00,0x00,0x3C,0x36,0x36,0x36,0x36,0x36,0x00,0x00 ,
149 0x00,0x00,0x00,0x00,0x1C,0x36,0x36,0x36,0x36,0x1C,0x00,0x00 ,
150 0x00,0x00,0x00,0x00,0x3C,0x36,0x36,0x36,0x36,0x3C,0x30,0x30 ,
151 0x00,0x00,0x00,0x00,0x1E,0x36,0x36,0x36,0x36,0x1E,0x06,0x06 ,
152 0x00,0x00,0x00,0x00,0x36,0x3E,0x30,0x30,0x30,0x30,0x00,0x00 ,
153 0x00,0x00,0x00,0x00,0x1E,0x30,0x3C,0x1E,0x06,0x3C,0x00,0x00 ,
154 0x00,0x00,0x18,0x18,0x3C,0x18,0x18,0x18,0x18,0x0E,0x00,0x00 ,
155 0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x36,0x36,0x1E,0x00,0x00 ,
156 0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x36,0x1C,0x08,0x00,0x00 ,
157 0x00,0x00,0x00,0x00,0x63,0x6B,0x6B,0x6B,0x3E,0x36,0x00,0x00 ,
158 0x00,0x00,0x00,0x00,0x36,0x36,0x1C,0x1C,0x36,0x36,0x00,0x00 ,
159 0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x36,0x1C,0x0C,0x18,0x30 ,
160 0x00,0x00,0x00,0x00,0x3E,0x06,0x0C,0x18,0x30,0x3E,0x00,0x00 ,
161 0x00,0x0E,0x18,0x18,0x18,0x30,0x18,0x18,0x18,0x0E,0x00,0x00 ,
162 0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18 ,
163 0x00,0x30,0x18,0x18,0x18,0x0C,0x18,0x18,0x18,0x30,0x00,0x00 ,
164 0x00,0x1A,0x3E,0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
165 0x00,0x00,0x00,0x08,0x1C,0x36,0x22,0x22,0x3E,0x3E,0x00,0x00 ,
170 fwrite(&oneByte, 1, 1,
foutJpg);
178 static void setPixel(
unsigned char *pixel,
int wi,
int hi,
int numColorChannel,
int x,
int y,
unsigned char rgb_color[3])
180 if( x >= 0 && x < wi && y >= 0 && y < hi)
182 int pixAdr = numColorChannel * (y * wi + x);
183 pixel[pixAdr + 0] = rgb_color[0];
184 pixel[pixAdr + 1] = rgb_color[1];
185 pixel[pixAdr + 2] = rgb_color[2];
189 static void drawLine(
unsigned char *pixel,
int wi,
int hi,
int numColorChannel,
int startpoint[2],
int endpoint[2],
float color[3])
191 int x0 = startpoint[0], y0 = startpoint[1], x1 = endpoint[0], y1 = endpoint[1];
192 unsigned char rgb_color[3] = { (
unsigned char)((
int)(255.999 *
color[0])&0xFF), (
unsigned char)((
int)(255.999 *
color[1])&0xFF), (
unsigned char)((
int)(255.999 *
color[2])&0xFF) };
193 int dx = abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
194 int dy = abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
195 int err = (dx > dy ? dx : -dy) / 2, e2;
198 setPixel(pixel, wi, hi, numColorChannel, x0, y0, rgb_color);
199 if (x0 == x1 && y0 == y1)
break;
201 if (e2 > -dx) { err -= dy; x0 += sx; }
202 if (e2 < dy) { err += dx; y0 += sy; }
206 static void drawText(
unsigned char *pixel,
int wi,
int hi,
int numColorChannel,
const std::string& text,
int pos[2],
float color[3])
208 unsigned char rgb_color[3] = { (
unsigned char)((
int)(255.999 *
color[0])&0xFF), (
unsigned char)((
int)(255.999 *
color[1])&0xFF), (
unsigned char)((
int)(255.999 *
color[2])&0xFF) };
209 int strLen = (int)text.length();
211 for (
int i = 0; i < strLen; i++)
214 if ((ch >=
' ') && (ch < 0x80))
217 int offset = idx * 12;
218 for (
int ii = 0; ii < 12; ii++)
221 for (
int jj = 0; jj < 8; jj++)
223 if (ucBitMask & (0x01 << (7 - jj)))
225 setPixel(pixel, wi, hi, numColorChannel, xTmp + jj, pos[1] + ii, rgb_color);
242 ROS_DEBUG_STREAM(
"plotPointCloud: outputfolder=\"" << outputfolder <<
"\"");
243 const unsigned char *cloudDataPtr = &(cloud_.data[0]);
244 int w = cloud_.width;
245 int h = cloud_.height;
247 int numShots = w * h;
249 float *ptr = (
float *) cloudDataPtr;
251 if (cnt == intervall)
253 std::string filename_tmpl = outputfolder +
"/scan";
255 std::replace( filename_tmpl.begin(), filename_tmpl.end(),
'/',
'\\');
257 std::replace( filename_tmpl.begin(), filename_tmpl.end(),
'\\',
'/');
259 std::string jpgFileName_tmp = filename_tmpl +
".jpg_tmp";
265 int hi = h2i * 2 + 1;
266 int wi = w2i * 2 + 1;
267 int pixNum = hi * wi;
268 int numColorChannel = 3;
269 unsigned char *pixel = (
unsigned char *) malloc(numColorChannel * hi * wi);
270 memset(pixel, 0, numColorChannel * pixNum);
271 double scaleFac = 50.0;
273 for (
int i = 0; i < hi; i++)
275 int pixAdr = numColorChannel * (i * wi + xic);
276 pixel[pixAdr] = 0x40;
277 pixel[pixAdr + 1] = 0x40;
278 pixel[pixAdr + 2] = 0x40;
280 for (
int i = 0; i < wi; i++)
282 int pixAdr = numColorChannel * (yic * wi + i);
283 pixel[pixAdr] = 0x40;
284 pixel[pixAdr + 1] = 0x40;
285 pixel[pixAdr + 2] = 0x40;
289 for (
int i = 0; i < numShots; i++)
291 double x, y, z, intensity;
297 int xi = (x * scaleFac) + xic;
298 int yi = (y * scaleFac) + yic;
299 if ((xi >= 0) && (xi < wi))
301 if ((yi >= 0) && (xi < hi))
305 int pixAdr = numColorChannel * (xi * wi + yi);
307 unsigned char color[3] = {0x00};
325 for (
int kk = 0; kk < 3; kk++)
327 pixel[pixAdr + kk] =
color[kk];
341 float marker_pos[3] = { (float)
marker.pose.position.x, (
float)
marker.pose.position.y, (float)
marker.pose.position.z };
342 std::string marker_text =
marker.text;
343 if(
marker.type == ros_visualization_msgs::Marker::TRIANGLE_LIST)
345 for(
int point_idx = 2; point_idx <
marker.points.size(); point_idx+=3)
347 int triangle_p0[2] = { (int)(
marker.points[point_idx - 2].y * scaleFac + xic), (int)(
marker.points[point_idx - 2].x * scaleFac + yic) };
348 int triangle_p1[2] = { (int)(
marker.points[point_idx - 1].y * scaleFac + xic), (int)(
marker.points[point_idx - 1].x * scaleFac + yic) };
349 int triangle_p2[2] = { (int)(
marker.points[point_idx - 0].y * scaleFac + xic), (int)(
marker.points[point_idx - 0].x * scaleFac + yic) };
350 if(point_idx <
marker.colors.size())
351 marker_rgba =
marker.colors[point_idx];
352 float marker_color[3] = { (
float)marker_rgba.r, (float)marker_rgba.g, (
float)marker_rgba.b };
353 drawLine(pixel, wi, hi, numColorChannel, triangle_p0, triangle_p1, marker_color);
354 drawLine(pixel, wi, hi, numColorChannel, triangle_p1, triangle_p2, marker_color);
355 drawLine(pixel, wi, hi, numColorChannel, triangle_p2, triangle_p1, marker_color);
358 else if(
marker.type == ros_visualization_msgs::Marker::TEXT_VIEW_FACING)
360 int text_pos[2] = { (int)(2 * marker_pos[1] * scaleFac + xic), (int)(3 * marker_pos[0] * scaleFac + yic) };
361 int text_bias = ((text_pos[0] < xic) ? -1 : 0) * 8 * marker_text.length();
362 text_pos[0] += text_bias;
363 float text_color[3] = { (float)marker_rgba.r, (
float)marker_rgba.g, (float)marker_rgba.b };
364 drawText(pixel, wi, hi, numColorChannel, marker_text, text_pos, text_color);
368 ROS_INFO_STREAM(
"visualization_marker[" << marker_idx <<
"]: type=" << (
int)
marker.type <<
" NOT supported, text=" << marker_text <<
", pos=(" << marker_pos[0] <<
"," << marker_pos[1] <<
"," << marker_pos[1] <<
"), "
369 <<
", color_rgb=(" << marker_rgba.r <<
"," << marker_rgba.g <<
"," << marker_rgba.b <<
"), " << (
marker.points.size()) <<
" points.");
374 foutJpg = fopen(jpgFileName_tmp.c_str(),
"wb");
377 ROS_INFO_STREAM(
"Demo file " << jpgFileName_tmp <<
" not created. Check existience of demo dir. or patch code.\n");
385 std::string jpgFileName_out = filename_tmpl +
".jpg";
387 _unlink(jpgFileName_out.c_str());
388 rename(jpgFileName_tmp.c_str(), jpgFileName_out.c_str());
390 rename(jpgFileName_tmp.c_str(), jpgFileName_out.c_str());
395 std::string csvFileNameTmp = filename_tmpl +
".csv_tmp";
396 FILE *foutCsv = fopen(csvFileNameTmp.c_str(),
"w");
400 fprintf(foutCsv,
"timestamp_sec;timestamp_nanosec;range;azimuth_deg;elevation_deg;x;y;z;intensity\n");
401 const unsigned char *cloudDataPtr = &(cloud_.data[0]);
403 int numShots = w * h;
405 float *ptr = (
float *) cloudDataPtr;
408 long timestamp_sec = cloud_.header.stamp.sec;
409 long timestamp_nanosec = cloud_.header.stamp.nsec;
410 for (
int i = 0; i < numShots; i++)
412 double x, y, z, intensity;
416 float range_xy = sqrt(x*x+y*y);
417 float range_xyz = sqrt(x*x+y*y+z*z);
418 float elevation = atan2(z, range_xy);
419 float azimuth = atan2(y,x);
420 float elevationDeg = elevation * 180.0 / M_PI;
421 float azimuthDeg = azimuth * 180.0 / M_PI;
425 fprintf(foutCsv,
"%12ld;%12ld;%8.3lf;%8.3lf;%8.3lf;%8.3f;%8.3f;%8.3f;%8.0f\n", timestamp_sec, timestamp_nanosec, range_xyz, azimuthDeg, elevationDeg, x,y,z,intensity);
428 std::string csvFileNameOut = filename_tmpl +
".csv";
430 _unlink(csvFileNameOut.c_str());
431 rename(csvFileNameTmp.c_str(), csvFileNameOut.c_str());
433 rename(csvFileNameTmp.c_str(), csvFileNameOut.c_str());
438 ROS_INFO_STREAM(
"Demo file " << csvFileNameTmp <<
" not created. Check existience of demo dir. or patch code.\n");