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.
-
#-(other) ⇒ Duration
create a new duration.
-
#initialize(secs = 0, nsecs = nil) ⇒ Duration
constructor
A new instance of Duration.
-
#sleep ⇒ Object
sleep while this duration.
Methods inherited from TimeValue
#<=>, #canonicalize, #to_nsec, #to_sec
Constructor Details
#initialize(secs) ⇒ Duration #initialize(secs, nsecs) ⇒ Duration
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 |
#-(other) ⇒ Duration
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 |
#sleep ⇒ Object
sleep while this duration
58 59 60 |
# File 'lib/ros/duration.rb', line 58 def sleep Kernel.sleep(to_sec) end |