@@ -229,24 +229,41 @@ void TrackerObjectDebugger::draw(
229
229
marker_track_boxes.scale .y = 0.4 ;
230
230
marker_track_boxes.scale .z = 0.4 ;
231
231
232
- visualization_msgs::msg::Marker marker_detect_boxes;
233
- marker_detect_boxes = marker;
234
- marker_detect_boxes.ns = " detect_boxes" ;
235
- marker_detect_boxes.type = visualization_msgs::msg::Marker::CUBE_LIST;
236
- marker_detect_boxes.action = visualization_msgs::msg::Marker::ADD;
237
- marker_detect_boxes.scale .x = 0.2 ;
238
- marker_detect_boxes.scale .y = 0.2 ;
239
- marker_detect_boxes.scale .z = 0.2 ;
240
-
241
- visualization_msgs::msg::Marker marker_lines;
242
- marker_lines = marker;
243
- marker_lines.ns = " association_lines" ;
244
- marker_lines.type = visualization_msgs::msg::Marker::LINE_LIST;
245
- marker_lines.action = visualization_msgs::msg::Marker::ADD;
246
- marker_lines.scale .x = 0.15 ;
247
- marker_lines.points .clear ();
248
-
249
- bool is_line_drawn = false ;
232
+ // make detected object markers per channel
233
+ std::vector<visualization_msgs::msg::Marker> marker_detect_boxes_per_channel;
234
+ std::vector<visualization_msgs::msg::Marker> marker_detect_lines_per_channel;
235
+
236
+ for (size_t idx = 0 ; idx < channel_names_.size (); idx++) {
237
+ // get color - by channel index
238
+ std_msgs::msg::ColorRGBA color;
239
+ color.a = 1.0 ;
240
+ color.r = color_array[idx % PALETTE_SIZE][0 ];
241
+ color.g = color_array[idx % PALETTE_SIZE][1 ];
242
+ color.b = color_array[idx % PALETTE_SIZE][2 ];
243
+
244
+ visualization_msgs::msg::Marker marker_detect_boxes;
245
+ marker_detect_boxes = marker;
246
+ marker_detect_boxes.ns = " detect_boxes_" + channel_names_[idx];
247
+ marker_detect_boxes.type = visualization_msgs::msg::Marker::CUBE_LIST;
248
+ marker_detect_boxes.action = visualization_msgs::msg::Marker::ADD;
249
+ marker_detect_boxes.scale .x = 0.2 ;
250
+ marker_detect_boxes.scale .y = 0.2 ;
251
+ marker_detect_boxes.scale .z = 0.2 ;
252
+ marker_detect_boxes.color = color;
253
+ marker_detect_boxes_per_channel.push_back (marker_detect_boxes);
254
+
255
+ visualization_msgs::msg::Marker marker_lines;
256
+ marker_lines = marker;
257
+ marker_lines.ns = " association_lines_" + channel_names_[idx];
258
+ marker_lines.type = visualization_msgs::msg::Marker::LINE_LIST;
259
+ marker_lines.action = visualization_msgs::msg::Marker::ADD;
260
+ marker_lines.scale .x = 0.15 ;
261
+ marker_lines.points .clear ();
262
+ marker_lines.color = color;
263
+ marker_detect_lines_per_channel.push_back (marker_lines);
264
+ }
265
+
266
+ bool is_any_associated = false ;
250
267
251
268
for (const auto & object_data : object_data_group) {
252
269
int channel_id = object_data.channel_id ;
@@ -260,39 +277,51 @@ void TrackerObjectDebugger::draw(
260
277
261
278
// set association marker, if exists
262
279
if (!object_data.is_associated ) continue ;
263
- is_line_drawn = true ;
264
- // get color - by channel index
265
- std_msgs::msg::ColorRGBA color;
266
- color.a = 1.0 ;
267
- color.r = color_array[channel_id % PALETTE_SIZE][0 ];
268
- color.g = color_array[channel_id % PALETTE_SIZE][1 ];
269
- color.b = color_array[channel_id % PALETTE_SIZE][2 ];
280
+ is_any_associated = true ;
281
+
282
+ // associated object box
283
+ visualization_msgs::msg::Marker & marker_detect_boxes =
284
+ marker_detect_boxes_per_channel.at (channel_id);
285
+ box_point.x = object_data.detection_point .x ;
286
+ box_point.y = object_data.detection_point .y ;
287
+ box_point.z = object_data.detection_point .z + height_offset + 1 ;
288
+ marker_detect_boxes.points .push_back (box_point);
270
289
271
290
// association line
291
+ visualization_msgs::msg::Marker & marker_lines =
292
+ marker_detect_lines_per_channel.at (channel_id);
272
293
geometry_msgs::msg::Point line_point;
273
- marker_lines.color = color;
274
-
275
294
line_point.x = object_data.tracker_point .x ;
276
295
line_point.y = object_data.tracker_point .y ;
277
296
line_point.z = object_data.tracker_point .z + height_offset;
278
297
marker_lines.points .push_back (line_point);
279
298
line_point.x = object_data.detection_point .x ;
280
299
line_point.y = object_data.detection_point .y ;
281
- line_point.z = object_data.tracker_point .z + height_offset + 1 ;
300
+ line_point.z = object_data.detection_point .z + height_offset + 1 ;
282
301
marker_lines.points .push_back (line_point);
283
-
284
- // associated object box
285
- box_point.x = object_data.detection_point .x ;
286
- box_point.y = object_data.detection_point .y ;
287
- box_point.z = object_data.detection_point .z + height_offset + 1 ;
288
- marker_detect_boxes.color = color;
289
- marker_detect_boxes.points .push_back (box_point);
290
302
}
291
303
292
304
// add markers
293
305
marker_array.markers .push_back (marker_track_boxes);
294
- marker_array.markers .push_back (marker_detect_boxes);
295
- if (is_line_drawn) marker_array.markers .push_back (marker_lines);
306
+ if (is_any_associated) {
307
+ for (size_t i = 0 ; i < channel_names_.size (); i++) {
308
+ if (marker_detect_boxes_per_channel.at (i).points .empty ()) continue ;
309
+ marker_array.markers .push_back (marker_detect_boxes_per_channel.at (i));
310
+ }
311
+ for (size_t i = 0 ; i < channel_names_.size (); i++) {
312
+ if (marker_detect_lines_per_channel.at (i).points .empty ()) continue ;
313
+ marker_array.markers .push_back (marker_detect_lines_per_channel.at (i));
314
+ }
315
+ } else {
316
+ for (size_t i = 0 ; i < channel_names_.size (); i++) {
317
+ marker_detect_boxes_per_channel.at (i).action = visualization_msgs::msg::Marker::DELETE;
318
+ marker_array.markers .push_back (marker_detect_boxes_per_channel.at (i));
319
+ }
320
+ for (size_t i = 0 ; i < channel_names_.size (); i++) {
321
+ marker_detect_lines_per_channel.at (i).action = visualization_msgs::msg::Marker::DELETE;
322
+ marker_array.markers .push_back (marker_detect_lines_per_channel.at (i));
323
+ }
324
+ }
296
325
}
297
326
298
327
return ;
@@ -317,15 +346,17 @@ void TrackerObjectDebugger::getMessage(visualization_msgs::msg::MarkerArray & ma
317
346
delete_marker.ns = " existence_probability" ;
318
347
delete_marker.id = previous_id;
319
348
delete_marker.action = visualization_msgs::msg::Marker::DELETE;
320
-
321
349
marker_array.markers .push_back (delete_marker);
322
350
323
351
delete_marker.ns = " track_boxes" ;
324
352
marker_array.markers .push_back (delete_marker);
325
- delete_marker.ns = " detect_boxes" ;
326
- marker_array.markers .push_back (delete_marker);
327
- delete_marker.ns = " association_lines" ;
328
- marker_array.markers .push_back (delete_marker);
353
+
354
+ for (size_t idx = 0 ; idx < channel_names_.size (); idx++) {
355
+ delete_marker.ns = " detect_boxes_" + channel_names_[idx];
356
+ marker_array.markers .push_back (delete_marker);
357
+ delete_marker.ns = " association_lines_" + channel_names_[idx];
358
+ marker_array.markers .push_back (delete_marker);
359
+ }
329
360
}
330
361
331
362
return ;
0 commit comments