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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 430 times

Last updated: Apr 22 '19