Skip to content

Commit 735ff04

Browse files
committed
add last_diagnostic_duration
1 parent f97a3df commit 735ff04

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ur_robot_driver/src/ros/hardware_interface_node.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ int main(int argc, char** argv)
200200
msgStats pub_temp_stats;
201201
reset_msg_stats(pub_temp_stats);
202202

203+
std::chrono::duration<double> last_diagnostics_duration = std::chrono::duration<double>::zero();
204+
203205
long debug_loops = 0;
204206

205207
// Debug timing printout every 5 seconds
@@ -276,6 +278,11 @@ int main(int argc, char** argv)
276278
push_msg_stats(robot_status, "read: pub_robot", pub_robot_stats, debug_loops);
277279
push_msg_stats(robot_status, "read: pub_temp", pub_temp_stats, debug_loops);
278280

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+
279286
dia_array.status.push_back(robot_status);
280287
diagnostic_pub.publish(dia_array);
281288

@@ -292,14 +299,15 @@ int main(int argc, char** argv)
292299
reset_msg_stats(pub_temp_stats);
293300
debug_loops = 0;
294301
debug_timing_start = debug_timing_now;
302+
last_diagnostics_duration = debug_timing_now - std::chrono::steady_clock::now();
295303
}
296304

297305
// if (!control_rate.sleep())
298-
if (period.toSec() > expected_cycle_time)
299-
{
306+
// if (period.toSec() > expected_cycle_time)
307+
// {
300308
// ROS_WARN_STREAM("Could not keep cycle rate of " << expected_cycle_time * 1000 << "ms");
301309
// ROS_WARN_STREAM("Actual cycle time:" << period.toNSec() / 1000000.0 << "ms");
302-
}
310+
// }
303311
}
304312

305313
spinner.stop();

0 commit comments

Comments
 (0)