Package roslib :: Module rostime :: Class TVal

Class TVal

source code

object --+
         |
        TVal
Known Subclasses:

Base class of Time and Duration representations. Representation is secs+nanoseconds since epoch.

Instance Methods
 
__init__(self, secs=0, nsecs=0)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
bool
is_zero(self)
Returns: True if time is zero (secs and nsecs are zero)
source code
 
set(self, secs, nsecs)
Set time using separate secs and nsecs values
source code
 
canon(self)
Canonicalize the field representation in this instance.
source code
float
to_sec(self)
Returns: time as float seconds (same as time.time() representation)
source code
long
to_nsec(self)
Returns: time as nanoseconds
source code
 
__hash__(self)
Time values are hashable.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__nonzero__(self)
Check if time value is zero
source code
 
__lt__(self, other)
< test for time values
source code
 
__le__(self, other)
<= test for time values
source code
 
__gt__(self, other)
> test for time values
source code
 
__ge__(self, other)
>= test for time values
source code
 
__ne__(self, other) source code
 
__cmp__(self, other) source code
 
__eq__(self, other) source code

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

Properties
  nsecs
  secs

Inherited from object: __class__

Method Details

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

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • secs (int/float) - seconds. If secs is a float, then nsecs must not be set or 0
  • nsecs (int) - nanoseconds
Overrides: object.__init__

is_zero(self)

source code 
Returns: bool
True if time is zero (secs and nsecs are zero)

set(self, secs, nsecs)

source code 

Set time using separate secs and nsecs values

Parameters:
  • secs (int) - seconds since epoch
  • nsecs (int) - nanoseconds since seconds

canon(self)

source code 

Canonicalize the field representation in this instance. should only be used when manually setting secs/nsecs slot values, as in deserialization.

to_sec(self)

source code 
Returns: float
time as float seconds (same as time.time() representation)

to_nsec(self)

source code 
Returns: long
time as nanoseconds

__hash__(self)
(Hashing function)

source code 

Time values are hashable. Time values with identical fields have the same hash.

Overrides: object.__hash__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)