ros::Time doesn't update in variable
I have trimmed most of the irrelevant code from this post.
int main(int argc, char **argv)
{
float f_grabtime;
do
{
ROS_INFO("\n###############################################");
f_grabtime = ros::Time::now().toSec();
ROS_INFO("f_grabtime = : %6.4f", f_grabtime);
DummyFunction();
ROS_INFO("ros::Time::now().toSec(); %6.4f", ros::Time::now().toSec());
ROS_INFO("delta time; %6.4f", ros::Time::now().toSec() - f_grabtime);
}
while (ros::ok());
return 0;
} //end main
When run, I get the output:
###############################################
[ INFO] [1378668866.709873391]: f_grabtime = : 1378668928.0000
[ INFO] [1378668866.709900160]: ros::Time::now().toSec(); 1378668866.7099
[ INFO] [1378668866.709920681]: delta time; -61.2901
[ INFO] [1378668866.881583005]:
###############################################
[ INFO] [1378668866.881641471]: f_grabtime = : 1378668928.0000
[ INFO] [1378668866.881672380]: ros::Time::now().toSec(); 1378668866.8817
[ INFO] [1378668866.881696694]: delta time; -61.1183
[ INFO] [1378668867.037738183]:
###############################################
[ INFO] [1378668867.037806140]: f_grabtime = : 1378668928.0000
[ INFO] [1378668867.037836070]: ros::Time::now().toSec(); 1378668867.0378
[ INFO] [1378668867.037860362]: delta time; -60.9622
[ INFO] [1378668867.201626074]:
###############################################
[ INFO] [1378668867.201681767]: f_grabtime = : 1378668928.0000
[ INFO] [1378668867.201705114]: ros::Time::now().toSec(); 1378668867.2017
[ INFO] [1378668867.201727003]: delta time; -60.7983
A) why does f_grabtime have a value in the future?
B) why doesn't it update at every loop (as the raw ros::Time callout does)?