Ask Your Question
0

An outer loop with a slower ros::Rate() and an inner loop with a faster ros::Rate() logic

asked 2015-11-19 01:15:28 -0500

Juan gravatar image

Consider the situation where there is an outer control loop and an inner control loop. The outer loop runs at 100Hz and the inner loop runs at 500Hz. The inner loop will run 5 times before the outer loop gets called again.

However, the logic of the program would only like the outer loop to run after the inner loop finishes its cycle and sets a flag as true.

What happens in this situation? Does the outer loop forces itself to run again and re-writes data from the yet unfinished return value of the inner loop?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-11-25 11:12:03 -0500

Wolf gravatar image

I think I'd just set up 2 ros::Timer instances with different timeouts and different callbacks for both loops and then call ros::spin() in the main loop to let the callback be "fired". If you use the "normal" ros::spin() and not MultithreadedSpinner or AsynchSpinner it is safe to assume that your 2 callbacks wo'nt be called at the same time in parallel.....

edit flag offensive delete link more
0

answered 2015-11-26 13:33:54 -0500

Shawn Schaerer gravatar image

Do you still want the outer loop to run at 100hz? What are you trying to do?

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

1 follower

Stats

Asked: 2015-11-19 01:15:28 -0500

Seen: 116 times

Last updated: Nov 26 '15