Query on get_clock()->now()
Hi,
I am trying to update the msg header stamp using the below method.
custom_msg.header.stamp = get_clock()->now();
Seems like this updates both sec
and nanosec
field in the stamp
.
In the subscriber node, I need to use this timestamp to calculate the time difference. I have pasted the sample output below.
header:
stamp:
sec: 1593787132
nanosec: 472017003
frame_id: custom_node
---
header:
stamp:
sec: 1593787132
nanosec: 672051846
frame_id: custom_node
---
header:
stamp:
sec: 1593787132
nanosec: 872009918
frame_id: custom_node
---
header:
stamp:
sec: 1593787133
nanosec: 71999048
frame_id: custom_node
---
header:
stamp:
sec: 1593787133
nanosec: 271995190
frame_id: custom_node
---
header:
stamp:
sec: 1593787133
nanosec: 471998850
frame_id: custom_node
---
header:
stamp:
sec: 1593787133
nanosec: 671974068
frame_id: custom_node
---
header:
stamp:
sec: 1593787133
nanosec: 871955846
frame_id: custom_node
---
Looks like I can not use the time in sec
as it not changing in every cycle.
And in nanosec
the time value decreases in some of the cycles resulting in negative difference.
Could anybody please explain how the nanosec
is being updated. My understanding is that the value has to increase in each cycle.
Thank you, KK