From aa32a046b605fcad8cabf7410e222a9d89b13721 Mon Sep 17 00:00:00 2001 From: light-tech Date: Fri, 4 Nov 2022 14:42:05 +0700 Subject: [PATCH] Fix const-ness in std::chrono::time_point construction and explicitly use std::chrono::nanoseconds as std::chrono::time_point template parameter to help compilation on macOS as its std::chrono::system_clock::time_point defaults to std::chrono::milliseconds for duration type (#848) --- controller_manager/src/ros2_control_node.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/ros2_control_node.cpp b/controller_manager/src/ros2_control_node.cpp index b8468318ac..ff91342940 100644 --- a/controller_manager/src/ros2_control_node.cpp +++ b/controller_manager/src/ros2_control_node.cpp @@ -62,8 +62,9 @@ int main(int argc, char ** argv) // for calculating sleep time auto const period = std::chrono::nanoseconds(1'000'000'000 / cm->get_update_rate()); - std::chrono::system_clock::time_point next_iteration_time = - std::chrono::system_clock::time_point(std::chrono::nanoseconds(cm->now().nanoseconds())); + auto const cm_now = std::chrono::nanoseconds(cm->now().nanoseconds()); + std::chrono::time_point + next_iteration_time{cm_now}; // for calculating the measured period of the loop rclcpp::Time previous_time = cm->now();