@@ -130,6 +130,16 @@ ObjectAssociationMergerNode::ObjectAssociationMergerNode(const rclcpp::NodeOptio
130
130
stop_watch_ptr_->tic (" cyclic_time" );
131
131
stop_watch_ptr_->tic (" processing_time" );
132
132
published_time_publisher_ = std::make_unique<autoware_utils::PublishedTimePublisher>(this );
133
+ // Timeout process initialization
134
+ message_timeout_sec_ = this ->declare_parameter <double >(" message_timeout_sec" , 0.001 );
135
+ last_sync_time_ = this ->now ();
136
+ timeout_sent_ = false ;
137
+ timeout_timer_ = this ->create_wall_timer (
138
+ std::chrono::duration<double >(message_timeout_sec_),
139
+ std::bind (&ObjectAssociationMergerNode::timeoutCallback, this ));
140
+ diagnostics_interface_ptr_ =
141
+ std::make_unique<autoware_utils::DiagnosticsInterface>(this , " object_association_merger" );
142
+
133
143
}
134
144
135
145
void ObjectAssociationMergerNode::objectsCallback (
@@ -142,6 +152,15 @@ void ObjectAssociationMergerNode::objectsCallback(
142
152
}
143
153
stop_watch_ptr_->toc (" processing_time" , true );
144
154
155
+
156
+ // If messages normally synced
157
+ diagnostics_interface_ptr_->clear ();
158
+ diagnostics_interface_ptr_->add_key_value (" are_merge_messages_synced" , true );
159
+ diagnostics_interface_ptr_->add_key_value (" messages_interval" , (this ->now () - last_sync_time_).seconds () );
160
+ diagnostics_interface_ptr_->publish (input_objects0_msg->header .stamp );
161
+ last_sync_time_ = this ->now ();
162
+ timeout_sent_ = false ;
163
+
145
164
/* transform to base_link coordinate */
146
165
autoware_perception_msgs::msg::DetectedObjects transformed_objects0, transformed_objects1;
147
166
if (
@@ -238,6 +257,27 @@ void ObjectAssociationMergerNode::objectsCallback(
238
257
processing_time_publisher_->publish <autoware_internal_debug_msgs::msg::Float64Stamped>(
239
258
" debug/processing_time_ms" , stop_watch_ptr_->toc (" processing_time" , true ));
240
259
}
260
+
261
+
262
+ void ObjectAssociationMergerNode::timeoutCallback ()
263
+ {
264
+ rclcpp::Time now = this ->now ();
265
+ if ((now - last_sync_time_).seconds () >= message_timeout_sec_ && !timeout_sent_) {
266
+ diagnostics_interface_ptr_->clear ();
267
+ diagnostics_interface_ptr_->add_key_value (" are_merge_messages_synced" , false );
268
+ diagnostics_interface_ptr_->add_key_value (" messages_interval" , (now - last_sync_time_).seconds () );
269
+
270
+
271
+ std::stringstream message;
272
+ message << " ObjectAssociationMergerNode Timeout: Merging messages not received" ;
273
+ diagnostics_interface_ptr_->update_level_and_message (
274
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str ());
275
+ diagnostics_interface_ptr_->publish (now);
276
+ timeout_sent_ = true ;
277
+ }
278
+ }
279
+
280
+
241
281
} // namespace autoware::object_merger
242
282
243
283
#include < rclcpp_components/register_node_macro.hpp>
0 commit comments