Class: ROS::TimeValue
- Inherits:
- 
      Object
      
        - Object
- ROS::TimeValue
 
- Includes:
- Comparable
- Defined in:
- lib/ros/time.rb
Overview
super class of times
Instance Attribute Summary (collapse)
- 
  
    
      - (Integer) nsecs 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Nano seconds. 
- 
  
    
      - (Integer) secs 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Seconds. 
Instance Method Summary (collapse)
- 
  
    
      - (Integer) <=>(other) 
    
    
  
  
  
  
  
  
  
  
  
    compare time value. 
- 
  
    
      - (TimeValue) canonicalize 
    
    
  
  
  
  
  
  
  
  
  
    canonicalize secs and nsecs. 
- 
  
    
      - (Float) to_nsec 
    
    
  
  
  
  
  
  
  
  
  
    convert to nano seconds. 
- 
  
    
      - (Float) to_sec 
    
    
  
  
  
  
  
  
  
  
  
    convert to seconds. 
Instance Attribute Details
- (Integer) nsecs
Returns nano seconds
| 24 25 26 | # File 'lib/ros/time.rb', line 24 def nsecs @nsecs end | 
- (Integer) secs
Returns seconds
| 21 22 23 | # File 'lib/ros/time.rb', line 21 def secs @secs end | 
Instance Method Details
- (Integer) <=>(other)
compare time value
| 55 56 57 58 59 60 61 62 63 64 | # File 'lib/ros/time.rb', line 55 def <=>(other) diff = self.to_nsec - other.to_nsec if diff > 0 1 elsif diff < 0 -1 else 0 end end | 
- (TimeValue) canonicalize
canonicalize secs and nsecs
| 28 29 30 31 32 33 34 35 36 37 38 | # File 'lib/ros/time.rb', line 28 def canonicalize while @nsecs >= 1e9.to_i @secs += 1 @nsecs -= 1e9.to_i end while @nsecs < 0 @secs -= 1 @nsecs += 1e9.to_i end self end | 
- (Float) to_nsec
convert to nano seconds
| 48 49 50 | # File 'lib/ros/time.rb', line 48 def to_nsec @nsecs + (@secs * 1e9) end | 
- (Float) to_sec
convert to seconds
| 42 43 44 | # File 'lib/ros/time.rb', line 42 def to_sec @secs + (@nsecs / 1e9) end |