ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Long while loop might crash ros::Rate.sleep()?

asked 2019-04-21 13:54:57 -0500

RicoJ gravatar image

ros::Rate loop_rate(8); // 8Hz while(ros::ok()) { Kalman_Filter.filter_control(); ros::spin_once(); loop_rate.sleep(); }

The function Kalman_Filter.filter_control() is a state machine and one state runs on 1Hz, while the rest of the code runs on 8Hz. Will this crash loop_rate.sleep()?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-04-22 07:47:21 -0500

gvdhoorn gravatar image

No (or at least: not because the code takes too long, there could still be other problems with it of course).

It will just mean that loop_rate.sleep() will return immediately after the "one state [that] runs on 1Hz" has finished, as there is no more time to sleep.

The function Kalman_Filter.filter_control() is a state machine and one state runs on 1Hz, while the rest of the code runs on 8Hz. Will this crash loop_rate.sleep()?

What makes you wonder whether it will crash? Also: what is a crash for you?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-04-21 13:54:57 -0500

Seen: 509 times

Last updated: Apr 22 '19