Time taken for each loop is different for while(ros :: ok)
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.
Just an observation (and a warning, as I see this done incorrectly by many people):
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 totrue
.And I would also suggest to include code (ie: show exactly what you are doing to measure this) and output of running that code.