Package rospy :: Module rostime :: Class Duration

Class Duration

source code

        object --+        
genpy.rostime.TVal --+    
genpy.rostime.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.


 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 = - 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
source code

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

Inherited from genpy.rostime.TVal: __bool__, __ge__, __gt__, __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__

Class Methods

Inherited from genpy.rostime.TVal: from_sec


Inherited from genpy.rostime.Duration: nsecs, secs

Inherited from object: __class__

Method Details

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

source code 

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

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

(Representation operator)

source code 


Overrides: object.__repr__
(inherited documentation)