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

rospy absolute duration bug

asked 2015-06-26 08:38:19 -0600

jbv gravatar image

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
edit retag flag offensive close merge delete

Comments

I think you'd better report this to the genpyissue tracker.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-26 08:46:24 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-26 09:10:23 -0600

jbv gravatar image

updated 2015-06-26 19:54:32 -0600

tfoote gravatar image
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-26 08:38:19 -0600

Seen: 361 times

Last updated: Jun 26 '15