Skip to content

Commit 7b8c2bc

Browse files
committed
fix: rename to latest_exported_object_time_
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent 9d71cce commit 7b8c2bc

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

perception/multi_object_tracker/include/multi_object_tracker/processor/input_manager.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class InputManager
138138
std::vector<rclcpp::Subscription<DetectedObjects>::SharedPtr> sub_objects_array_{};
139139

140140
bool is_initialized_{false};
141-
rclcpp::Time latest_object_time_;
141+
rclcpp::Time latest_exported_object_time_;
142142

143143
size_t input_size_;
144144
std::vector<std::shared_ptr<InputStream>> input_streams_;

perception/multi_object_tracker/src/processor/input_manager.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void InputStream::getObjectsOlderThan(
176176
////////////////////////////
177177
InputManager::InputManager(rclcpp::Node & node) : node_(node)
178178
{
179-
latest_object_time_ = node_.now();
179+
latest_exported_object_time_ = node_.now() - rclcpp::Duration::from_seconds(3.0);
180180
}
181181

182182
void InputManager::init(const std::vector<InputChannel> & input_channels)
@@ -239,7 +239,7 @@ void InputManager::getObjectTimeInterval(
239239
rclcpp::Time latest_measurement_time =
240240
input_streams_.at(target_stream_idx_)->getLatestMeasurementTime();
241241

242-
// if the object_latest_time is older than the latest measurement time, set it as the latest
242+
// if the object_latest_time is older than the latest measurement time, set it to the latest
243243
// object time
244244
object_latest_time =
245245
object_latest_time < latest_measurement_time ? latest_measurement_time : object_latest_time;
@@ -248,8 +248,9 @@ void InputManager::getObjectTimeInterval(
248248
object_oldest_time = object_latest_time - rclcpp::Duration::from_seconds(1.0);
249249
// if the object_oldest_time is older than the latest object time, set it to the latest object
250250
// time
251-
object_oldest_time =
252-
object_oldest_time > latest_object_time_ ? object_oldest_time : latest_object_time_;
251+
object_oldest_time = object_oldest_time < latest_exported_object_time_
252+
? latest_exported_object_time_
253+
: object_oldest_time;
253254
}
254255

255256
void InputManager::optimizeTimings()
@@ -320,19 +321,20 @@ bool InputManager::getObjects(const rclcpp::Time & now, ObjectsList & objects_li
320321
0;
321322
});
322323

323-
// Update the latest object time
324+
// Update the latest exported object time
324325
bool is_any_object = !objects_list.empty();
325326
if (is_any_object) {
326-
latest_object_time_ = rclcpp::Time(objects_list.back().second.header.stamp);
327+
latest_exported_object_time_ = rclcpp::Time(objects_list.back().second.header.stamp);
327328
} else {
328329
// check time jump
329-
if (now < latest_object_time_) {
330+
if (now < latest_exported_object_time_) {
330331
RCLCPP_WARN(
331332
node_.get_logger(),
332-
"InputManager::getObjects Time jump detected, now: %f, latest_object_time_: %f",
333-
now.seconds(), latest_object_time_.seconds());
334-
latest_object_time_ =
335-
now - rclcpp::Duration::from_seconds(3.0); // reset the latest object time to 3 seconds ago
333+
"InputManager::getObjects Time jump detected, now: %f, latest_exported_object_time_: %f",
334+
now.seconds(), latest_exported_object_time_.seconds());
335+
latest_exported_object_time_ =
336+
now - rclcpp::Duration::from_seconds(
337+
3.0); // reset the latest exported object time to 3 seconds ago
336338
} else {
337339
RCLCPP_DEBUG(
338340
node_.get_logger(),

0 commit comments

Comments
 (0)