Package rospy :: Module rostime :: Class Duration

Class Duration

source code

        object --+        
                 |        
genpy.rostime.TVal --+    
                     |    
genpy.rostime.Duration --+
                         |
                        Duration

Duration represents the ROS 'duration' primitive type, which consists of two integers: seconds and nanoseconds. The Duration class allows you to add and subtract Duration instances, including adding and subtracting from Time instances.

Usage:

 five_seconds = Duration(5)
 five_nanoseconds = Duration(0, 5)

 print 'Fields are', five_seconds.secs, five_seconds.nsecs

 # Duration arithmetic
 ten_seconds = five_seconds + five_seconds
 five_secs_ago = rospy.Time.now() - five_seconds # Time minus Duration is a Time

 true_val = ten_second > five_seconds
Instance Methods
 
__init__(self, secs=0, nsecs=0)
Create new Duration instance.
source code
 
__repr__(self)
repr(x)
source code

Inherited from genpy.rostime.Duration: __abs__, __add__, __cmp__, __div__, __eq__, __floordiv__, __getstate__, __mul__, __neg__, __setstate__, __sub__, __truediv__

Inherited from genpy.rostime.TVal: __ge__, __gt__, __hash__, __le__, __lt__, __ne__, __nonzero__, __str__, canon, is_zero, set, to_nsec, to_sec

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Static Methods

Inherited from genpy.rostime.Duration: from_sec

Properties

Inherited from genpy.rostime.Duration: nsecs, secs

Inherited from object: __class__

Method Details

__init__(self, secs=0, nsecs=0)
(Constructor)

source code 

Create new Duration instance. secs and nsecs are integers and correspond to the ROS 'duration' primitive type.

Parameters:
  • secs (int) - seconds
  • nsecs (int) - nanoseconds
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)