Class: ROS::Duration
Overview
ROS Duration object
This is used as msg object for duration
Instance Attribute Summary
Attributes inherited from TimeValue
Instance Method Summary (collapse)
-
- (Duration) +(duration)
create a new duration.
-
- (Duration) -(other)
create a new duration.
-
- (Duration) initialize(secs = 0, nsecs = nil)
constructor
A new instance of Duration.
-
- (Object) sleep
sleep while this duration.
Methods inherited from TimeValue
#<=>, #canonicalize, #to_nsec, #to_sec
Constructor Details
- (Duration) initialize(secs) - (Duration) initialize(secs, nsecs)
Returns a new instance of Duration
27 28 29 30 31 32 33 34 35 |
# File 'lib/ros/duration.rb', line 27 def initialize(secs=0, nsecs=nil) @secs = secs.to_i if nsecs @nsecs = nsecs else @nsecs = ((secs - @secs) * 1e9.to_i).to_i end canonicalize end |
Instance Method Details
- (Duration) +(duration)
create a new duration
40 41 42 43 44 45 |
# File 'lib/ros/duration.rb', line 40 def +(duration) tm = ::ROS::Duration.new tm.secs = @secs + duration.secs tm.nsecs = @nsecs + duration.nsecs tm.canonicalize end |
- (Duration) -(other)
create a new duration
50 51 52 53 54 55 |
# File 'lib/ros/duration.rb', line 50 def -(other) d = ::ROS::Duration.new d.secs = @secs - other.secs d.nsecs = @nsecs - other.nsecs d.canonicalize end |
- (Object) sleep
sleep while this duration
58 59 60 |
# File 'lib/ros/duration.rb', line 58 def sleep Kernel.sleep(to_sec) end |