Skip to content

Commit 1440e23

Browse files
committedMar 18, 2025·
Update sorting condition
1 parent e8efcd2 commit 1440e23

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎perception/multi_object_tracker/src/processor/processor.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@ void TrackerProcessor::removeOverlappedTracker(const rclcpp::Time & time)
183183
list_tracker_.begin(), list_tracker_.end());
184184
std::sort(
185185
sorted_list_tracker.begin(), sorted_list_tracker.end(),
186-
[](const std::shared_ptr<Tracker> & a, const std::shared_ptr<Tracker> & b) {
186+
[&time](const std::shared_ptr<Tracker> & a, const std::shared_ptr<Tracker> & b) {
187187
bool a_unknown = (a->getHighestProbLabel() == Label::UNKNOWN);
188188
bool b_unknown = (b->getHighestProbLabel() == Label::UNKNOWN);
189189
if (a_unknown != b_unknown) {
190190
return b_unknown; // Put non-UNKNOWN objects first
191191
}
192-
return a->getTotalMeasurementCount() >
193-
b->getTotalMeasurementCount(); // Then sort by measurement count
192+
if (a->getTotalMeasurementCount() != b->getTotalMeasurementCount()) {
193+
return a->getTotalMeasurementCount() > b->getTotalMeasurementCount(); // Then sort by measurement count
194+
}
195+
return a->getElapsedTimeFromLastUpdate(time) < b->getElapsedTimeFromLastUpdate(time); // Finally sort by elapsed time (smaller first)
194196
});
195197

196198
/* Iterate through the list of trackers */

0 commit comments

Comments
 (0)
Please sign in to comment.