@@ -200,6 +200,8 @@ int main(int argc, char** argv)
200
200
msgStats pub_temp_stats;
201
201
reset_msg_stats (pub_temp_stats);
202
202
203
+ std::chrono::duration<double > last_diagnostics_duration = std::chrono::duration<double >::zero ();
204
+
203
205
long debug_loops = 0 ;
204
206
205
207
// Debug timing printout every 5 seconds
@@ -276,6 +278,11 @@ int main(int argc, char** argv)
276
278
push_msg_stats (robot_status, " read: pub_robot" , pub_robot_stats, debug_loops);
277
279
push_msg_stats (robot_status, " read: pub_temp" , pub_temp_stats, debug_loops);
278
280
281
+ diagnostic_msgs::KeyValue diagnostic_duration_kv;
282
+ diagnostic_duration_kv.key = " Last diagnostic duration (s)" ;
283
+ diagnostic_duration_kv.value = std::to_string (last_diagnostics_duration.count ());
284
+ robot_status.values .push_back (diagnostic_duration_kv);
285
+
279
286
dia_array.status .push_back (robot_status);
280
287
diagnostic_pub.publish (dia_array);
281
288
@@ -292,14 +299,15 @@ int main(int argc, char** argv)
292
299
reset_msg_stats (pub_temp_stats);
293
300
debug_loops = 0 ;
294
301
debug_timing_start = debug_timing_now;
302
+ last_diagnostics_duration = debug_timing_now - std::chrono::steady_clock::now ();
295
303
}
296
304
297
305
// if (!control_rate.sleep())
298
- if (period.toSec () > expected_cycle_time)
299
- {
306
+ // if (period.toSec() > expected_cycle_time)
307
+ // {
300
308
// ROS_WARN_STREAM("Could not keep cycle rate of " << expected_cycle_time * 1000 << "ms");
301
309
// ROS_WARN_STREAM("Actual cycle time:" << period.toNSec() / 1000000.0 << "ms");
302
- }
310
+ // }
303
311
}
304
312
305
313
spinner.stop ();
0 commit comments