From the documentation (http://docs.ros.org/melodic/api/rostime/html/classros_1_1Time.html#a84cd12a499c70fb3eefce89cda2b6113), ros::Time::isValid returns "whether or not the current time is valid. Time is valid if it is non-zero".
However, a trivial example is enough to show that the implementation does not do this:
#include <ros/ros.h>
int main(int argc, char** argv) {
ros::init(argc, argv, "rostime_example");
ros::NodeHandle n;
// default construct a time
ros::Time t;
ROS_WARN_STREAM("time value: " <<t.toSec());
ROS_WARN_STREAM("time valid: " <<t.isValid());
return 0;
}
The output is:
ivaughn@ros-pc:~/test_ws$ rosrun rostime_example node
[ WARN] [1561399516.961348750]: time value: 0
[ WARN] [1561399516.961420491]: time valid: 1
Any idea what's going on here? Is this just a bug in ROS 1, or am I misunderstanding how this function is expected to behave.
We're kind of curious, behavior that does something different when a timestamp is invalid is often safety-critical. Thanks!
Originally posted by ivaughn_whoi on ROS Answers with karma: 13 on 2019-06-24
Post score: 1