Time taken for each loop is different for while(ros :: ok)

asked 2020-06-26 05:37:09 -0500

guilt11 gravatar image

I set up rate is 50, however, I use the ros::Time::now().toSec() to check the time taken for each loop (while(ros :: ok)), I find out the time taken for each loop is different, is it normal and why this happens?

I appreciate if anyone could help me.

edit retag flag offensive close merge delete

Comments

Just an observation (and a warning, as I see this done incorrectly by many people):

for each loop (while(ros :: ok))

It should be ros::ok(), notros::ok.

The former invokes a function which returns a bool. The latter is a function pointer, which will always evaluate to true.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-26 05:54:25 -0500 )edit

And I would also suggest to include code (ie: show exactly what you are doing to measure this) and output of running that code.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-26 06:33:55 -0500 )edit