Skip to content

Commit 104dac4

Browse files
committed
feat: print channel names
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent b6f59a9 commit 104dac4

File tree

5 files changed

+73
-33
lines changed

5 files changed

+73
-33
lines changed

perception/multi_object_tracker/include/multi_object_tracker/debugger/debug_object.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ class TrackerObjectDebugger
7777
int32_t marker_id_ = 0;
7878
std::vector<std::vector<ObjectData>> object_data_groups_;
7979

80+
std::vector<std::string> channel_names_;
81+
8082
public:
83+
void setChannelNames(const std::vector<std::string> & channel_names)
84+
{
85+
channel_names_ = channel_names;
86+
}
8187
void collect(
8288
const rclcpp::Time & message_time, const std::list<std::shared_ptr<Tracker>> & list_tracker,
8389
const uint & channel_index,

perception/multi_object_tracker/include/multi_object_tracker/debugger/debugger.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <memory>
3232
#include <string>
3333
#include <unordered_map>
34+
#include <vector>
3435

3536
/**
3637
* @brief Debugger class for multi object tracker
@@ -89,6 +90,10 @@ class TrackerDebugger
8990
void checkDelay(diagnostic_updater::DiagnosticStatusWrapper & stat);
9091

9192
// Debug object
93+
void setObjectChannels(const std::vector<std::string> & channels)
94+
{
95+
object_debugger_.setChannelNames(channels);
96+
}
9297
void collectObjectInfo(
9398
const rclcpp::Time & message_time, const std::list<std::shared_ptr<Tracker>> & list_tracker,
9499
const uint & channel_index,

perception/multi_object_tracker/src/debugger/debug_object.cpp

+53-31
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <boost/uuid/uuid.hpp>
2020

2121
#include <functional>
22+
#include <iomanip>
23+
#include <sstream>
2224
#include <string>
2325

2426
TrackerObjectDebugger::TrackerObjectDebugger(std::string frame_id)
@@ -194,85 +196,103 @@ void TrackerObjectDebugger::draw(
194196
text_marker.ns = "existence_probability";
195197
text_marker.type = visualization_msgs::msg::Marker::TEXT_VIEW_FACING;
196198
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;
199201
text_marker.pose.position.x = object_data_front.tracker_point.x;
200202
text_marker.pose.position.y = object_data_front.tracker_point.y;
201203
text_marker.pose.position.z = object_data_front.tracker_point.z + 1.0;
202204

203205
// 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();
209213
}
214+
210215
text_marker.text = existence_probability_text;
211216
marker_array.markers.push_back(text_marker);
212217

213218
// loop for each object_data in the group
214219
// boxed to tracker positions
215220
// 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;
223240

224241
visualization_msgs::msg::Marker marker_lines;
225242
marker_lines = marker;
226243
marker_lines.ns = "association_lines";
227244
marker_lines.type = visualization_msgs::msg::Marker::LINE_LIST;
228245
marker_lines.action = visualization_msgs::msg::Marker::ADD;
229-
marker_lines.scale.x = 0.2;
246+
marker_lines.scale.x = 0.15;
230247
marker_lines.points.clear();
231248

249+
bool is_line_drawn = false;
250+
232251
for (const auto & object_data : object_data_group) {
252+
int channel_id = object_data.channel_id;
253+
233254
// set box
234255
geometry_msgs::msg::Point box_point;
235256
box_point.x = object_data.tracker_point.x;
236257
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);
242260

243261
// set association marker, if exists
244262
if (!object_data.is_associated) continue;
263+
is_line_drawn = true;
245264
// get color - by channel index
246265
std_msgs::msg::ColorRGBA color;
247266
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];
251270

252271
// association line
253272
geometry_msgs::msg::Point line_point;
254273
marker_lines.color = color;
255274

256275
line_point.x = object_data.tracker_point.x;
257276
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;
259278
marker_lines.points.push_back(line_point);
260279
line_point.x = object_data.detection_point.x;
261280
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;
263282
marker_lines.points.push_back(line_point);
264283

265284
// associated object box
266285
box_point.x = object_data.detection_point.x;
267286
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);
271290
}
272291

273292
// 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);
276296
}
277297

278298
return;
@@ -300,7 +320,9 @@ void TrackerObjectDebugger::getMessage(visualization_msgs::msg::MarkerArray & ma
300320

301321
marker_array.markers.push_back(delete_marker);
302322

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";
304326
marker_array.markers.push_back(delete_marker);
305327
delete_marker.ns = "association_lines";
306328
marker_array.markers.push_back(delete_marker);

perception/multi_object_tracker/src/multi_object_tracker_core.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ MultiObjectTracker::MultiObjectTracker(const rclcpp::NodeOptions & node_options)
166166

167167
// Debugger
168168
debugger_ = std::make_unique<TrackerDebugger>(*this, world_frame_id_);
169+
debugger_->setObjectChannels(input_names_short);
169170
published_time_publisher_ = std::make_unique<tier4_autoware_utils::PublishedTimePublisher>(this);
170171
}
171172

perception/multi_object_tracker/src/tracker/model/tracker_base.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Tracker::Tracker(
4343
void Tracker::initializeExistenceProbabilities(
4444
const uint & channel_index, const float & existence_probability)
4545
{
46-
existence_probabilities_[channel_index] = existence_probability;
46+
existence_probabilities_[channel_index] = 0.8 + 0.2 * existence_probability;
4747
total_existence_probability_ = existence_probability;
4848
}
4949

@@ -61,7 +61,13 @@ bool Tracker::updateWithMeasurement(
6161
// existence probability on each channel
6262
const double delta_time = (measurement_time - last_update_with_measurement_time_).seconds();
6363
const double decay_rate = 5.0 / 10.0;
64-
existence_probabilities_[channel_index] = existence_probability_from_object;
64+
65+
const float gain = 0.8;
66+
const float probability_detected = 0.8;
67+
// existence_probabilities_[channel_index] = existence_probability_from_object;
68+
existence_probabilities_[channel_index] =
69+
gain * probability_detected + (1 - gain) * existence_probabilities_[channel_index];
70+
6571
for (size_t i = 0; i < existence_probabilities_.size(); ++i) {
6672
if (i == channel_index) {
6773
continue;

0 commit comments

Comments
 (0)