Ask Your Question

Revision history [back]

This is rather strange, but there are a couple of things you could try.

Can you test the code with the if statement only containing last_publisher_ != TIME_MIN just to confirm that is causing the problem. Also you want to change .nanoseconds()/1000*1000*1000 to either .nanoseconds()/1000000000 or .nanoseconds()/(1000*1000*1000)

Are you deliberately creating a rclcpp::Time object as a copy of another Time object in the following line? The difference in the style of construction between TIME_MIN and last_published_ may be causing this problem (even though it probably shouldn't!).

rclcpp::Time last_published_(rclcpp::Time(std::numeric_limits<rcl_time_point_value_t>::min()));

This could be more succinctly written as:

rclcpp::Time last_published_(std::numeric_limits<rcl_time_point_value_t>::min());

If you construct TIME_MIN in the same way as below it may help:

rclcpp::Time TIME_MIN(std::numeric_limits<rcl_time_point_value_t>::min());

Hope this helps.