File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ int main(int argc, char ** argv)
93
93
}
94
94
}
95
95
96
+ // wait for the clock to be available
97
+ cm->get_clock ()->wait_until_started ();
98
+ cm->get_clock ()->sleep_for (rclcpp::Duration::from_seconds (1.0 / cm->get_update_rate ()));
99
+
96
100
RCLCPP_INFO (cm->get_logger (), " update rate is %d Hz" , cm->get_update_rate ());
97
101
const int thread_priority = cm->get_parameter_or <int >(" thread_priority" , kSchedPriority );
98
102
RCLCPP_INFO (
@@ -122,7 +126,7 @@ int main(int argc, char ** argv)
122
126
auto const period = std::chrono::nanoseconds (1'000'000'000 / cm->get_update_rate ());
123
127
auto const cm_now = std::chrono::nanoseconds (cm->now ().nanoseconds ());
124
128
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>
125
- next_iteration_time{cm_now};
129
+ next_iteration_time{cm_now - period };
126
130
127
131
// for calculating the measured period of the loop
128
132
rclcpp::Time previous_time = cm->now () - period;
You can’t perform that action at this time.
0 commit comments