Class: Std_msgs::MultiArrayDimension

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ MultiArrayDimension

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :label (string)

    initialize value

  • :size (uint32)

    initialize value

  • :stride (uint32)

    initialize value



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/std_msgs/MultiArrayDimension.rb', line 39

def initialize(args={})
  # message fields cannot be None, assign default values for those that are
  if args[:label]
    @label = args[:label]
  else
    @label = ''
  end
  if args[:size]
    @size = args[:size]
  else
    @size = 0
  end
  if args[:stride]
    @stride = args[:stride]
  else
    @stride = 0
  end
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#strideObject

Returns the value of attribute stride.



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

def stride
  @stride
end

Class Method Details

.md5sumObject



8
9
10
# File 'lib/std_msgs/MultiArrayDimension.rb', line 8

def self.md5sum
  "4cd0c83a8683deae40ecdac60e53bfa8"
end

.typeObject



12
13
14
# File 'lib/std_msgs/MultiArrayDimension.rb', line 12

def self.type
  "std_msgs/MultiArrayDimension"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



60
61
62
# File 'lib/std_msgs/MultiArrayDimension.rb', line 60

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


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/std_msgs/MultiArrayDimension.rb', line 80

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    start = end_point
    end_point += length
    @label = str[start..(end_point-1)]
    start = end_point
    end_point += ROS::Struct::calc_size('L2')
    (@size, @stride,) = @@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)


16
17
18
# File 'lib/std_msgs/MultiArrayDimension.rb', line 16

def has_header?
  false
end

#message_definitionObject



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

def message_definition
  "string label   # label of given dimension
uint32 size    # size of given dimension (in type units)
uint32 stride  # stride of given dimension
"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/std_msgs/MultiArrayDimension.rb', line 66

def serialize(buff)
  begin
    _x = @label
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_L2.pack(@size, @stride))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end