What's the mechanism of the header timestamp of ROS message?

asked 2019-08-21 07:49:44 -0600

I'm curious about the mechanism of the header timestamp of ROS message. I ran a rosbag that publish the Image topic. Then a node subscribes this topic:

ros::Subscriber sub_image = n.subscribe(IMAGE_TOPIC, 2000, image_callback);

The callback is something like this:

   queue<sensor_msgs::ImageConstPtr> image_buf;
   void image_callback(const sensor_msgs::ImageConstPtr &image_msg)
        printf(" image time %f \n", image_msg->header.stamp.toSec());

Then I took the image message from image_buf after a while and wrote image_msg->header.stamp.toSec() into a time.txt file. I found the header timestamp value increases compared to its value in rosbag. Why???

edit retag flag offensive close merge delete