Class: Std_msgs::MultiArrayLayout
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Std_msgs::MultiArrayLayout
- 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
-
#data_offset ⇒ Object
Returns the value of attribute data_offset.
-
#dim ⇒ Object
Returns the value of attribute dim.
Class Method Summary collapse
Instance Method Summary collapse
-
#_get_types ⇒ String
internal API method.
-
#deserialize(str) ⇒ Object
unpack serialized message in str into this message instance @param [String] str: byte array of serialized message.
- #has_header? ⇒ Boolean
-
#initialize(args = {}) ⇒ MultiArrayLayout
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ MultiArrayLayout
Constructor. You can set the default values using keyword operators.
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_offset ⇒ Object
Returns the value of attribute data_offset.
55 56 57 |
# File 'lib/std_msgs/MultiArrayLayout.rb', line 55 def data_offset @data_offset end |
#dim ⇒ Object
Returns the value of attribute dim.
55 56 57 |
# File 'lib/std_msgs/MultiArrayLayout.rb', line 55 def dim @dim end |
Class Method Details
.md5sum ⇒ Object
9 10 11 |
# File 'lib/std_msgs/MultiArrayLayout.rb', line 9 def self.md5sum "0fed2a11c13e11c5571b4e2a995a91a3" end |
.type ⇒ Object
13 14 15 |
# File 'lib/std_msgs/MultiArrayLayout.rb', line 13 def self.type "std_msgs/MultiArrayLayout" end |
Instance Method Details
#_get_types ⇒ String
internal API method
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
17 18 19 |
# File 'lib/std_msgs/MultiArrayLayout.rb', line 17 def has_header? false end |
#message_definition ⇒ Object
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 "# 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
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 |