Yaskawa-Global / motoros2

ROS 2 (rcl, rclc & micro-ROS) node for MotoPlus-compatible Yaskawa Motoman robot controllers
95 stars 16 forks source link

First debug log message after connecting to Agent has all-zeros timestamp #97

Open gavanderhoorn opened 1 year ago

gavanderhoorn commented 1 year ago

Minor, but the very first debug listener message received after MotoROS2 connects to the Agent has an all-zeros timestamp associated with it:

[2023-07-14 18:14:40.488481] [192.168.255.1:61992]: THU 1970-01-01 00:00:00.000 Found micro-ROS PC Agent

Everything before and after that is OK.

gavanderhoorn commented 1 year ago

I believe it's due to the conditional used:

https://github.com/Yaskawa-Global/motoros2/blob/f26d997598108eff7d944335a052c5b6761039fa/src/Debug.c#L58-L72

this checks whether the Agent is connected (g_Ros_Communication_AgentIsConnected), but it's likely MotoROS2 hasn't had a chance yet to sync time with the Agent leading to rmw_uros_epoch_nanos() to still return 0.

Perhaps a fallback could be added to use clock_gettime(..) not just when the Agent hasn't connected yet, but also when rmw_uros_epoch_nanos() returns 0?