Class: Std_msgs::MultiArrayLayout

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ MultiArrayLayout

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :dim (std_msgs/MultiArrayDimension[])

    initialize value

  • :data_offset (uint32)

    initialize value



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

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

Instance Attribute Details

#data_offsetObject

Returns the value of attribute data_offset.



55
56
57
# File 'lib/std_msgs/MultiArrayLayout.rb', line 55

def data_offset
  @data_offset
end

#dimObject

Returns the value of attribute dim.



55
56
57
# File 'lib/std_msgs/MultiArrayLayout.rb', line 55

def dim
  @dim
end

Class Method Details

.md5sumObject



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

def self.md5sum
  "0fed2a11c13e11c5571b4e2a995a91a3"
end

.typeObject



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

def self.type
  "std_msgs/MultiArrayLayout"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



83
84
85
# File 'lib/std_msgs/MultiArrayLayout.rb', line 83

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


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/std_msgs/MultiArrayLayout.rb', line 109

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    @dim = []
    length.times do
      val1 = Std_msgs::MultiArrayDimension.new
      start = end_point
      end_point += 4
      (length,) = @@struct_L.unpack(str[start..(end_point-1)])
      start = end_point
      end_point += length
      val1.label = str[start..(end_point-1)]
      _x = val1
      start = end_point
      end_point += ROS::Struct::calc_size('L2')
      (_x.size, _x.stride,) = @@struct_L2.unpack(str[start..(end_point-1)])
      @dim.push(val1)
    end
    start = end_point
    end_point += ROS::Struct::calc_size('L')
    (@data_offset,) = @@struct_L.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/MultiArrayLayout.rb', line 17

def has_header?
  false
end

#message_definitionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/std_msgs/MultiArrayLayout.rb', line 21

def message_definition
  "# The multiarray declares a generic multi-dimensional array of a
# particular data type.  Dimensions are ordered from outer most
# to inner most.

MultiArrayDimension[] dim # Array of dimension properties
uint32 data_offset        # padding bytes at front of data

# Accessors should ALWAYS be written in terms of dimension stride
# and specified outer-most dimension first.
# 
# multiarray(i,j,k) = data[data_offset + dim_stride[1]*i + dim_stride[2]*j + k]
#
# A standard, 3-channel 640x480 image with interleaved color channels
# would be specified as:
#
# dim[0].label  = \"height\"
# dim[0].size   = 480
# dim[0].stride = 3*640*480 = 921600  (note dim[0] stride is just size of image)
# dim[1].label  = \"width\"
# dim[1].size   = 640
# dim[1].stride = 3*640 = 1920
# dim[2].label  = \"channel\"
# dim[2].size   = 3
# dim[2].stride = 3
#
# multiarray(i,j,k) refers to the ith row, jth column, and kth channel.
================================================================================
MSG: std_msgs/MultiArrayDimension
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



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/std_msgs/MultiArrayLayout.rb', line 89

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

  end
end