@@ -96,7 +96,7 @@ FusionNode<Msg, ObjType>::FusionNode(
96
96
97
97
// sub rois
98
98
rois_subs_.resize (rois_number_);
99
- roi_stdmap_ .resize (rois_number_);
99
+ cached_roi_msgs_ .resize (rois_number_);
100
100
is_fused_.resize (rois_number_, false );
101
101
for (std::size_t roi_i = 0 ; roi_i < rois_number_; ++roi_i) {
102
102
std::function<void (const DetectedObjectsWithFeature::ConstSharedPtr msg)> roi_callback =
@@ -163,12 +163,12 @@ void FusionNode<Msg, Obj>::preprocess(Msg & ouput_msg __attribute__((unused)))
163
163
template <class Msg , class Obj >
164
164
void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_msg)
165
165
{
166
- if (sub_std_pair_ .second != nullptr ) {
166
+ if (cached_msg_ .second != nullptr ) {
167
167
stop_watch_ptr_->toc (" processing_time" , true );
168
168
timer_->cancel ();
169
- postprocess (*(sub_std_pair_ .second ));
170
- publish (*(sub_std_pair_ .second ));
171
- sub_std_pair_ .second = nullptr ;
169
+ postprocess (*(cached_msg_ .second ));
170
+ publish (*(cached_msg_ .second ));
171
+ cached_msg_ .second = nullptr ;
172
172
std::fill (is_fused_.begin (), is_fused_.end (), false );
173
173
174
174
// add processing time for debug
@@ -183,7 +183,7 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
183
183
}
184
184
}
185
185
186
- std::lock_guard<std::mutex> lock (mutex_ );
186
+ std::lock_guard<std::mutex> lock (mutex_cached_msgs_ );
187
187
auto period = std::chrono::duration_cast<std::chrono::nanoseconds>(
188
188
std::chrono::duration<double , std::milli>(timeout_ms_));
189
189
try {
@@ -211,12 +211,12 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
211
211
continue ;
212
212
}
213
213
214
- if ((roi_stdmap_ .at (roi_i)).size () > 0 ) {
214
+ if ((cached_roi_msgs_ .at (roi_i)).size () > 0 ) {
215
215
int64_t min_interval = 1e9 ;
216
216
int64_t matched_stamp = -1 ;
217
217
std::list<int64_t > outdate_stamps;
218
218
219
- for (const auto & [k, v] : roi_stdmap_ .at (roi_i)) {
219
+ for (const auto & [k, v] : cached_roi_msgs_ .at (roi_i)) {
220
220
int64_t new_stamp = timestamp_nsec + input_offset_ms_.at (roi_i) * (int64_t )1e6 ;
221
221
int64_t interval = abs (int64_t (k) - new_stamp);
222
222
@@ -230,7 +230,7 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
230
230
231
231
// remove outdated stamps
232
232
for (auto stamp : outdate_stamps) {
233
- (roi_stdmap_ .at (roi_i)).erase (stamp);
233
+ (cached_roi_msgs_ .at (roi_i)).erase (stamp);
234
234
}
235
235
236
236
// fuseOnSingle
@@ -240,9 +240,9 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
240
240
}
241
241
242
242
fuseOnSingleImage (
243
- *input_msg, roi_i, *((roi_stdmap_ .at (roi_i))[matched_stamp]), camera_info_map_. at (roi_i ),
244
- *output_msg);
245
- (roi_stdmap_ .at (roi_i)).erase (matched_stamp);
243
+ *input_msg, roi_i, *((cached_roi_msgs_ .at (roi_i))[matched_stamp]),
244
+ camera_info_map_. at (roi_i), *output_msg);
245
+ (cached_roi_msgs_ .at (roi_i)).erase (matched_stamp);
246
246
is_fused_.at (roi_i) = true ;
247
247
248
248
// add timestamp interval for debug
@@ -265,7 +265,7 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
265
265
postprocess (*output_msg);
266
266
publish (*output_msg);
267
267
std::fill (is_fused_.begin (), is_fused_.end (), false );
268
- sub_std_pair_ .second = nullptr ;
268
+ cached_msg_ .second = nullptr ;
269
269
270
270
// add processing time for debug
271
271
if (debug_publisher_) {
@@ -278,8 +278,8 @@ void FusionNode<Msg, Obj>::subCallback(const typename Msg::ConstSharedPtr input_
278
278
processing_time_ms = 0 ;
279
279
}
280
280
} else {
281
- sub_std_pair_ .first = int64_t (timestamp_nsec);
282
- sub_std_pair_ .second = output_msg;
281
+ cached_msg_ .first = int64_t (timestamp_nsec);
282
+ cached_msg_ .second = output_msg;
283
283
processing_time_ms = stop_watch_ptr_->toc (" processing_time" , true );
284
284
}
285
285
}
@@ -294,28 +294,28 @@ void FusionNode<Msg, Obj>::roiCallback(
294
294
(*input_roi_msg).header .stamp .sec * (int64_t )1e9 + (*input_roi_msg).header .stamp .nanosec ;
295
295
296
296
// if cached Msg exist, try to match
297
- if (sub_std_pair_ .second != nullptr ) {
298
- int64_t new_stamp = sub_std_pair_ .first + input_offset_ms_.at (roi_i) * (int64_t )1e6 ;
297
+ if (cached_msg_ .second != nullptr ) {
298
+ int64_t new_stamp = cached_msg_ .first + input_offset_ms_.at (roi_i) * (int64_t )1e6 ;
299
299
int64_t interval = abs (timestamp_nsec - new_stamp);
300
300
301
301
if (interval < match_threshold_ms_ * (int64_t )1e6 && is_fused_.at (roi_i) == false ) {
302
302
if (camera_info_map_.find (roi_i) == camera_info_map_.end ()) {
303
303
RCLCPP_WARN_THROTTLE (
304
304
this ->get_logger (), *this ->get_clock (), 5000 , " no camera info. id is %zu" , roi_i);
305
- (roi_stdmap_ .at (roi_i))[timestamp_nsec] = input_roi_msg;
305
+ (cached_roi_msgs_ .at (roi_i))[timestamp_nsec] = input_roi_msg;
306
306
return ;
307
307
}
308
308
if (debugger_) {
309
309
debugger_->clear ();
310
310
}
311
311
312
312
fuseOnSingleImage (
313
- *(sub_std_pair_ .second ), roi_i, *input_roi_msg, camera_info_map_.at (roi_i),
314
- *(sub_std_pair_ .second ));
313
+ *(cached_msg_ .second ), roi_i, *input_roi_msg, camera_info_map_.at (roi_i),
314
+ *(cached_msg_ .second ));
315
315
is_fused_.at (roi_i) = true ;
316
316
317
317
if (debug_publisher_) {
318
- double timestamp_interval_ms = (timestamp_nsec - sub_std_pair_ .first ) / 1e6 ;
318
+ double timestamp_interval_ms = (timestamp_nsec - cached_msg_ .first ) / 1e6 ;
319
319
debug_publisher_->publish <tier4_debug_msgs::msg::Float64Stamped>(
320
320
" debug/roi" + std::to_string (roi_i) + " /timestamp_interval_ms" , timestamp_interval_ms);
321
321
debug_publisher_->publish <tier4_debug_msgs::msg::Float64Stamped>(
@@ -325,10 +325,10 @@ void FusionNode<Msg, Obj>::roiCallback(
325
325
326
326
if (std::count (is_fused_.begin (), is_fused_.end (), true ) == static_cast <int >(rois_number_)) {
327
327
timer_->cancel ();
328
- postprocess (*(sub_std_pair_ .second ));
329
- publish (*(sub_std_pair_ .second ));
328
+ postprocess (*(cached_msg_ .second ));
329
+ publish (*(cached_msg_ .second ));
330
330
std::fill (is_fused_.begin (), is_fused_.end (), false );
331
- sub_std_pair_ .second = nullptr ;
331
+ cached_msg_ .second = nullptr ;
332
332
333
333
// add processing time for debug
334
334
if (debug_publisher_) {
@@ -346,7 +346,7 @@ void FusionNode<Msg, Obj>::roiCallback(
346
346
}
347
347
}
348
348
// store roi msg if not matched
349
- (roi_stdmap_ .at (roi_i))[timestamp_nsec] = input_roi_msg;
349
+ (cached_roi_msgs_ .at (roi_i))[timestamp_nsec] = input_roi_msg;
350
350
}
351
351
352
352
template <class Msg , class Obj >
@@ -360,13 +360,13 @@ void FusionNode<Msg, Obj>::timer_callback()
360
360
{
361
361
using std::chrono_literals::operator " " ms;
362
362
timer_->cancel ();
363
- if (mutex_ .try_lock ()) {
363
+ if (mutex_cached_msgs_ .try_lock ()) {
364
364
// timeout, postprocess cached msg
365
- if (sub_std_pair_ .second != nullptr ) {
365
+ if (cached_msg_ .second != nullptr ) {
366
366
stop_watch_ptr_->toc (" processing_time" , true );
367
367
368
- postprocess (*(sub_std_pair_ .second ));
369
- publish (*(sub_std_pair_ .second ));
368
+ postprocess (*(cached_msg_ .second ));
369
+ publish (*(cached_msg_ .second ));
370
370
371
371
// add processing time for debug
372
372
if (debug_publisher_) {
@@ -380,9 +380,9 @@ void FusionNode<Msg, Obj>::timer_callback()
380
380
}
381
381
}
382
382
std::fill (is_fused_.begin (), is_fused_.end (), false );
383
- sub_std_pair_ .second = nullptr ;
383
+ cached_msg_ .second = nullptr ;
384
384
385
- mutex_ .unlock ();
385
+ mutex_cached_msgs_ .unlock ();
386
386
} else {
387
387
try {
388
388
std::chrono::nanoseconds period = 10ms;
0 commit comments