Class: Std_msgs::Duration

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/std_msgs/Duration.rb

Constant Summary collapse

@@struct_l2 =
::ROS::Struct.new("l2")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['duration']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Duration

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :data (duration)

    initialize value



37
38
39
40
41
42
43
44
# File 'lib/std_msgs/Duration.rb', line 37

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

Instance Attribute Details

#dataObject

Returns the value of attribute data.



26
27
28
# File 'lib/std_msgs/Duration.rb', line 26

def data
  @data
end

Class Method Details

.md5sumObject



9
10
11
# File 'lib/std_msgs/Duration.rb', line 9

def self.md5sum
  "3e286caf4241d664e55f3ad380e2ae46"
end

.typeObject



13
14
15
# File 'lib/std_msgs/Duration.rb', line 13

def self.type
  "std_msgs/Duration"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



48
49
50
# File 'lib/std_msgs/Duration.rb', line 48

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


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/std_msgs/Duration.rb', line 65

def deserialize(str)

  begin
    if @data == nil
      @data = ROS::Duration.new
    end
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('l2')
    (@data.secs, @data.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/std_msgs/Duration.rb', line 17

def has_header?
  false
end

#message_definitionObject



21
22
23
24
25
# File 'lib/std_msgs/Duration.rb', line 21

def message_definition
  "duration data

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



54
55
56
57
58
59
60
61
# File 'lib/std_msgs/Duration.rb', line 54

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

  end
end