ros::Rate object- setting different loop_rates after instantiation

asked 2018-09-04 09:53:10 -0500

zeynep gravatar image

updated 2018-09-05 09:02:52 -0500

Hello,

I wrote a while loop and I want to change loop rates while running. The problem is , ros::Rate can only set frequency in constructor. After creating the object I can not change frequency.

How can I handle this problem.

Any help will be appreciated..

edit retag flag offensive close merge delete

Comments

1

Would constructing a new one and assigning it to the same variable not work?

gvdhoorn gravatar image gvdhoorn  ( 2018-09-04 11:12:15 -0500 )edit

I have 4 different loop_freq changing according to some conditions. will I create 4 different ros::Rate objects?

 ros::Rate loop_rate(loop_freq);
  while (ros::ok()){
        //do some work
        loop_freq= getLoopRate(); // loop_freq changes
        loop_rate.sleep();
zeynep gravatar image zeynep  ( 2018-09-05 02:05:19 -0500 )edit