I would like to get seconds, and nanoseconds from inside my node, so I have a timer_callback that executes each 100ms, to note seconds and nanoseconds of the rclcpp::Time
void timer_callback() {
rclcpp::Time t = this->now();
cout << unsigned(t.seconds()) << '\t' << unsigned(t.nanoseconds()) << endl;
}
What I get is, number of seconds since last epoch, and a uint32 representation of nanoseconds, that is actually accurate, (1sec=1e9ns), in which is measurable by chaning timer1 frequency, i.e. a diff of the nanoseconds is usable, but it does not reset each second, basically it has its own 4.2~ second epoch.
What is the epoch for nanoseconds?
Any ideas on how to get the seconds and nanoseconds to make a timestamp that is microseconds accurate?
Best Regards, C.A.
[node-1] 1697373475 3482658792
[node-1] 1697373475 3982695401
[node-1] 1697373476 187537493
[node-1] 1697373476 687584889
[node-1] 1697373477 1187751915
[node-1] 1697373477 1687731420
[node-1] 1697373478 2187763841
[node-1] 1697373478 2687771385
[node-1] 1697373479 3187776990
[node-1] 1697373479 3687628969