rospy absolute duration bug
Hello, I use ROS hydro and I think I found an error in the code of the rospy.Duration class
When I do :
print abs(rospy.Duration.from_sec(0.5))
it prints -500000000 instead of 500000000. That's because the code only takes into account the number of seconds. cf : https://github.com/ros/genpy/blob/ind...
def __abs__(self):
"""
Absolute value of this duration
:returns: positive :class:`Duration`
"""
if self.secs > 0:
return self
return self.__neg__()
It should be :
def __abs__(self):
"""
Absolute value of this duration
:returns: positive :class:`Duration`
"""
if self.secs < 0 or (self.secs == 0 and self.nsecs<0):
return self.__neg__()
return self
I think you'd better report this to the
genpy
issue tracker.