|
19 | 19 | #include <boost/uuid/uuid.hpp>
|
20 | 20 |
|
21 | 21 | #include <functional>
|
| 22 | +#include <iomanip> |
| 23 | +#include <sstream> |
22 | 24 | #include <string>
|
23 | 25 |
|
24 | 26 | TrackerObjectDebugger::TrackerObjectDebugger(std::string frame_id)
|
@@ -194,85 +196,103 @@ void TrackerObjectDebugger::draw(
|
194 | 196 | text_marker.ns = "existence_probability";
|
195 | 197 | text_marker.type = visualization_msgs::msg::Marker::TEXT_VIEW_FACING;
|
196 | 198 | text_marker.action = visualization_msgs::msg::Marker::ADD;
|
197 |
| - text_marker.pose.position.z += 1.5; |
198 |
| - text_marker.scale.z = 0.8; |
| 199 | + text_marker.pose.position.z += 1.8; |
| 200 | + text_marker.scale.z = 0.7; |
199 | 201 | text_marker.pose.position.x = object_data_front.tracker_point.x;
|
200 | 202 | text_marker.pose.position.y = object_data_front.tracker_point.y;
|
201 | 203 | text_marker.pose.position.z = object_data_front.tracker_point.z + 1.0;
|
202 | 204 |
|
203 | 205 | // show the last existence probability
|
204 |
| - std::string existence_probability_text = "P: "; |
205 |
| - for (const auto & existence_probability : object_data_front.existence_vector) { |
206 |
| - // probability to text, two digits of percentage |
207 |
| - existence_probability_text += |
208 |
| - std::to_string(static_cast<int>(existence_probability * 100)) + " "; |
| 206 | + // print existence probability with channel name |
| 207 | + // probability to text, two digits of percentage |
| 208 | + std::string existence_probability_text = "P:"; |
| 209 | + for (size_t i = 0; i < object_data_front.existence_vector.size(); ++i) { |
| 210 | + std::stringstream stream; |
| 211 | + stream << std::fixed << std::setprecision(0) << object_data_front.existence_vector[i] * 100; |
| 212 | + existence_probability_text += " " + channel_names_[i] + ":" + stream.str(); |
209 | 213 | }
|
| 214 | + |
210 | 215 | text_marker.text = existence_probability_text;
|
211 | 216 | marker_array.markers.push_back(text_marker);
|
212 | 217 |
|
213 | 218 | // loop for each object_data in the group
|
214 | 219 | // boxed to tracker positions
|
215 | 220 | // and link lines to the detected positions
|
216 |
| - const double line_height_offset = 1.0; |
217 |
| - |
218 |
| - visualization_msgs::msg::Marker marker_boxes; |
219 |
| - marker_boxes = marker; |
220 |
| - marker_boxes.ns = "boxes"; |
221 |
| - marker_boxes.type = visualization_msgs::msg::Marker::CUBE_LIST; |
222 |
| - marker_boxes.action = visualization_msgs::msg::Marker::ADD; |
| 221 | + const double height_offset = 1.0; |
| 222 | + |
| 223 | + visualization_msgs::msg::Marker marker_track_boxes; |
| 224 | + marker_track_boxes = marker; |
| 225 | + marker_track_boxes.ns = "track_boxes"; |
| 226 | + marker_track_boxes.type = visualization_msgs::msg::Marker::CUBE_LIST; |
| 227 | + marker_track_boxes.action = visualization_msgs::msg::Marker::ADD; |
| 228 | + marker_track_boxes.scale.x = 0.4; |
| 229 | + marker_track_boxes.scale.y = 0.4; |
| 230 | + marker_track_boxes.scale.z = 0.4; |
| 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; |
223 | 240 |
|
224 | 241 | visualization_msgs::msg::Marker marker_lines;
|
225 | 242 | marker_lines = marker;
|
226 | 243 | marker_lines.ns = "association_lines";
|
227 | 244 | marker_lines.type = visualization_msgs::msg::Marker::LINE_LIST;
|
228 | 245 | marker_lines.action = visualization_msgs::msg::Marker::ADD;
|
229 |
| - marker_lines.scale.x = 0.2; |
| 246 | + marker_lines.scale.x = 0.15; |
230 | 247 | marker_lines.points.clear();
|
231 | 248 |
|
| 249 | + bool is_line_drawn = false; |
| 250 | + |
232 | 251 | for (const auto & object_data : object_data_group) {
|
| 252 | + int channel_id = object_data.channel_id; |
| 253 | + |
233 | 254 | // set box
|
234 | 255 | geometry_msgs::msg::Point box_point;
|
235 | 256 | box_point.x = object_data.tracker_point.x;
|
236 | 257 | box_point.y = object_data.tracker_point.y;
|
237 |
| - box_point.z = object_data.tracker_point.z; |
238 |
| - marker_boxes.points.push_back(box_point); |
239 |
| - marker_boxes.scale.x = 0.2; |
240 |
| - marker_boxes.scale.y = 0.2; |
241 |
| - marker_boxes.scale.z = 0.2; |
| 258 | + box_point.z = object_data.tracker_point.z + height_offset; |
| 259 | + marker_track_boxes.points.push_back(box_point); |
242 | 260 |
|
243 | 261 | // set association marker, if exists
|
244 | 262 | if (!object_data.is_associated) continue;
|
| 263 | + is_line_drawn = true; |
245 | 264 | // get color - by channel index
|
246 | 265 | std_msgs::msg::ColorRGBA color;
|
247 | 266 | color.a = 1.0;
|
248 |
| - color.r = color_array[object_data.channel_id % PALETTE_SIZE][0]; |
249 |
| - color.g = color_array[object_data.channel_id % PALETTE_SIZE][1]; |
250 |
| - color.b = color_array[object_data.channel_id % PALETTE_SIZE][2]; |
| 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]; |
251 | 270 |
|
252 | 271 | // association line
|
253 | 272 | geometry_msgs::msg::Point line_point;
|
254 | 273 | marker_lines.color = color;
|
255 | 274 |
|
256 | 275 | line_point.x = object_data.tracker_point.x;
|
257 | 276 | line_point.y = object_data.tracker_point.y;
|
258 |
| - line_point.z = object_data.tracker_point.z + line_height_offset; |
| 277 | + line_point.z = object_data.tracker_point.z + height_offset; |
259 | 278 | marker_lines.points.push_back(line_point);
|
260 | 279 | line_point.x = object_data.detection_point.x;
|
261 | 280 | line_point.y = object_data.detection_point.y;
|
262 |
| - line_point.z = object_data.tracker_point.z + line_height_offset + 2; |
| 281 | + line_point.z = object_data.tracker_point.z + height_offset + 1; |
263 | 282 | marker_lines.points.push_back(line_point);
|
264 | 283 |
|
265 | 284 | // associated object box
|
266 | 285 | box_point.x = object_data.detection_point.x;
|
267 | 286 | box_point.y = object_data.detection_point.y;
|
268 |
| - box_point.z = object_data.detection_point.z; |
269 |
| - marker_boxes.color = color; |
270 |
| - marker_boxes.points.push_back(box_point); |
| 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); |
271 | 290 | }
|
272 | 291 |
|
273 | 292 | // add markers
|
274 |
| - marker_array.markers.push_back(marker_boxes); |
275 |
| - marker_array.markers.push_back(marker_lines); |
| 293 | + 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); |
276 | 296 | }
|
277 | 297 |
|
278 | 298 | return;
|
@@ -300,7 +320,9 @@ void TrackerObjectDebugger::getMessage(visualization_msgs::msg::MarkerArray & ma
|
300 | 320 |
|
301 | 321 | marker_array.markers.push_back(delete_marker);
|
302 | 322 |
|
303 |
| - delete_marker.ns = "boxes"; |
| 323 | + delete_marker.ns = "track_boxes"; |
| 324 | + marker_array.markers.push_back(delete_marker); |
| 325 | + delete_marker.ns = "detect_boxes"; |
304 | 326 | marker_array.markers.push_back(delete_marker);
|
305 | 327 | delete_marker.ns = "association_lines";
|
306 | 328 | marker_array.markers.push_back(delete_marker);
|
|
0 commit comments