Package roslib :: Module rostime :: Class Duration

Class Duration

source code

object --+    
         |    
      TVal --+
             |
            Duration
Known Subclasses:

Duration represents the ROS 'duration' primitive, 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.

Instance Methods
 
__init__(self, secs=0, nsecs=0)
Create new Duration instance.
source code
 
__getstate__(self)
support for Python pickling
source code
 
__setstate__(self, state)
support for Python pickling
source code
 
__repr__(self)
repr(x)
source code
Duration
__neg__(self)
Returns: Negative value of this duration
source code
Duration
__abs__(self)
Absolute value of this duration
source code
 
__add__(self, other)
Add duration to this duration, or this duration to a time, creating a new time value as a result.
source code
 
__sub__(self, other)
Subtract duration from this duration, returning a new duration
source code
Duration
__mul__(self, val)
Multiply this duration by an integer or float
source code
Duration
__floordiv__(self, val)
Floor divide this duration by an integer or float
source code
Duration
__div__(self, val)
Divide this duration by an integer or float
source code
Duration
__truediv__(self, val)
Divide this duration by an integer or float
source code
 
__cmp__(self, other) source code
 
__eq__(self, other) source code
 
__ge__(self, other)
>= test for time values (Inherited from roslib.rostime.TVal)
source code
 
__gt__(self, other)
> test for time values (Inherited from roslib.rostime.TVal)
source code
 
__hash__(self)
Time values are hashable. (Inherited from roslib.rostime.TVal)
source code
 
__le__(self, other)
<= test for time values (Inherited from roslib.rostime.TVal)
source code
 
__lt__(self, other)
< test for time values (Inherited from roslib.rostime.TVal)
source code
 
__ne__(self, other) (Inherited from roslib.rostime.TVal) source code
 
__nonzero__(self)
Check if time value is zero (Inherited from roslib.rostime.TVal)
source code
 
__str__(self)
str(x) (Inherited from roslib.rostime.TVal)
source code
 
canon(self)
Canonicalize the field representation in this instance. (Inherited from roslib.rostime.TVal)
source code
bool
is_zero(self)
Returns: True if time is zero (secs and nsecs are zero) (Inherited from roslib.rostime.TVal)
source code
 
set(self, secs, nsecs)
Set time using separate secs and nsecs values (Inherited from roslib.rostime.TVal)
source code
long
to_nsec(self)
Returns: time as nanoseconds (Inherited from roslib.rostime.TVal)
source code
float
to_sec(self)
Returns: time as float seconds (same as time.time() representation) (Inherited from roslib.rostime.TVal)
source code

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

Static Methods
Duration
from_sec(float_seconds)
Create new Duration instance from float seconds format.
source code
Properties
  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.

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

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

from_sec(float_seconds)
Static Method

source code 

Create new Duration instance from float seconds format.

Parameters:
  • float_seconds (float) - time value in specified as float seconds
Returns: Duration
Duration instance for specified float_seconds

__neg__(self)

source code 
Returns: Duration
Negative value of this duration

__abs__(self)

source code 

Absolute value of this duration

Returns: Duration
positive duration

__add__(self, other)
(Addition operator)

source code 

Add duration to this duration, or this duration to a time, creating a new time value as a result.

Parameters:
Returns:
Duration if other is a Duration, Time if other is a Time

__sub__(self, other)
(Subtraction operator)

source code 

Subtract duration from this duration, returning a new duration

Parameters:
Returns:
Duration

__mul__(self, val)

source code 

Multiply this duration by an integer or float

Parameters:
  • val (int/float) - multiplication factor
Returns: Duration
Duration multiplied by val

__floordiv__(self, val)

source code 

Floor divide this duration by an integer or float

Parameters:
  • val (int/float) - division factor
Returns: Duration
Duration multiplied by val

__div__(self, val)

source code 

Divide this duration by an integer or float

Parameters:
  • val (int/float) - division factor
Returns: Duration
Duration multiplied by val

__truediv__(self, val)

source code 

Divide this duration by an integer or float

Parameters:
  • val (int/float) - division factor
Returns: Duration
Duration multiplied by val

__cmp__(self, other)
(Comparison operator)

source code 
Overrides: TVal.__cmp__

__eq__(self, other)
(Equality operator)

source code 
Overrides: TVal.__eq__