ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You're calling ros::spinOnce() at 10Hz, which means that it can only call the callbacks once every 100ms; in between it queues up messages until you call ros::spinOnce() again. If you need to respond to events with lower latency, you should call ros::spinOnce() more often or use ros::spin() and do your publishing with a timer or a separate thread.

It's also worth noting that there is a publish timestamp in the nav_msgs/Odometry header (in your case, msg->header.stamp ), which is the time that the data was captured or published, and that will be more accurate than using the time that your node received the message (ie ros::Time::now() ). Since there can be some transport delay between nodes, it's generally advisable to use the header timestamp whenever possible.