Package roslib :: Module rostime :: Class Time

Class Time

source code

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

Time contains the ROS-wide 'time' primitive representation, which consists of two integers: seconds since epoch and nanoseconds since seconds. Time instances are mutable.

Instance Methods
 
__init__(self, secs=0, nsecs=0)
Constructor: secs and nsecs are integers.
source code
 
__getstate__(self)
support for Python pickling
source code
 
__setstate__(self, state)
support for Python pickling
source code
float
to_time(self)
Get Time in time.time() format.
source code
 
__repr__(self)
repr(x)
source code
 
__add__(self, other)
Add duration to this time
source code
 
__sub__(self, other)
Subtract time or duration from this time
source code
 
__cmp__(self, other)
Compare to another time
source code
 
__eq__(self, other)
Equals test for Time.
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
Time
from_seconds(*args, **kwargs)
Use from_sec() instead.
source code
Time
from_sec(float_secs)
Create new Time instance using time.time() value (float seconds)
source code
Properties
  nsecs
  secs

Inherited from object: __class__

Method Details

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

source code 

Constructor: secs and nsecs are integers. You may prefer to use the static from_sec() factory method instead.

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

from_seconds(*args, **kwargs)
Static Method

source code 

Use from_sec() instead. This is retained for backwards compatibility.

Parameters:
  • float_secs (float) - time value in time.time() format
Returns: Time
Time instance for specified time
Decorators:
  • @deprecated

from_sec(float_secs)
Static Method

source code 

Create new Time instance using time.time() value (float seconds)

Parameters:
  • float_secs (float) - time value in time.time() format
Returns: Time
Time instance for specified time

to_time(self)

source code 

Get Time in time.time() format. alias of to_sec()

Returns: float
time in floating point secs (time.time() format)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__add__(self, other)
(Addition operator)

source code 

Add duration to this time

Parameters:

__sub__(self, other)
(Subtraction operator)

source code 

Subtract time or duration from this time

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

__cmp__(self, other)
(Comparison operator)

source code 

Compare to another time

Parameters:
  • other (Time) - Time
Overrides: TVal.__cmp__

__eq__(self, other)
(Equality operator)

source code 

Equals test for Time. Comparison assumes that both time instances are in canonical representation; only compares fields.

Parameters:
  • other (Time) - Time
Overrides: TVal.__eq__