Class: Rosgraph_msgs::Clock

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/rosgraph_msgs/Clock.rb

Constant Summary collapse

@@struct_L2 =
::ROS::Struct.new("L2")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['time']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Clock

Constructor. You can set the default values using keyword operators.

Parameters:

  • args (Hash) (defaults to: {})

    keyword for initializing values

Options Hash (args):

  • :clock (time)

    initialize value



40
41
42
43
44
45
46
47
# File 'lib/rosgraph_msgs/Clock.rb', line 40

def initialize(args={})
  # message fields cannot be None, assign default values for those that are
  if args[:clock]
    @clock = args[:clock]
  else
    @clock = ROS::Time.new
  end
end

Instance Attribute Details

#clockObject

Returns the value of attribute clock.



29
30
31
# File 'lib/rosgraph_msgs/Clock.rb', line 29

def clock
  @clock
end

Class Method Details

.md5sumObject



9
10
11
# File 'lib/rosgraph_msgs/Clock.rb', line 9

def self.md5sum
  "a9c97c1d230cfc112e270351a944ee47"
end

.typeObject



13
14
15
# File 'lib/rosgraph_msgs/Clock.rb', line 13

def self.type
  "rosgraph_msgs/Clock"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



51
52
53
# File 'lib/rosgraph_msgs/Clock.rb', line 51

def _get_types
  @slot_types
end

#deserialize(str) ⇒ Object

unpack serialized message in str into this message instance

@param [String] str: byte array of serialized message


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rosgraph_msgs/Clock.rb', line 68

def deserialize(str)

  begin
    if @clock == nil
      @clock = ROS::Time.new
    end
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('L2')
    (@clock.secs, @clock.nsecs,) = @@struct_L2.unpack(str[start..(end_point-1)])
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rosgraph_msgs/Clock.rb', line 17

def has_header?
  false
end

#message_definitionObject



21
22
23
24
25
26
27
28
# File 'lib/rosgraph_msgs/Clock.rb', line 21

def message_definition
  "# roslib/Clock is used for publishing simulated time in ROS. 
# This message simply communicates the current time.
# For more information, see http://www.ros.org/wiki/Clock
time clock

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



57
58
59
60
61
62
63
64
# File 'lib/rosgraph_msgs/Clock.rb', line 57

def serialize(buff)
  begin
    buff.write(@@struct_L2.pack(@clock.secs, @clock.nsecs))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end