TypeError: Cannot compare to non-Duration
I want to ignore the immediate call to a function. Hence I need to keep track of the time at which the function was invoked. In other words, I want to skip the function call, if the function is being called before defined time.
Below is the code snippet:
# define time interval
dt = rospy.Time(secs=2)
old = rospy.Time.now()
# doing some task here
now = rospy.Time.now()
if (now - old < dt):
print 'Ignoring immediate call'
Although, the logic looks fine but the code throws following error at runtime:
TypeError: Cannot compare to non-Duration
Any workaround, please?