Class: Std_msgs::Int64MultiArray
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Std_msgs::Int64MultiArray
- Defined in:
- lib/std_msgs/Int64MultiArray.rb
Constant Summary collapse
- @@struct_L2 =
::ROS::Struct.new("L2")
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['std_msgs/MultiArrayLayout','int64[]']
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#layout ⇒ Object
Returns the value of attribute layout.
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 = {}) ⇒ Int64MultiArray
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ Int64MultiArray
Constructor. You can set the default values using keyword operators.
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 77 def initialize(args={}) # message fields cannot be None, assign default values for those that are if args[:layout] @layout = args[:layout] else @layout = Std_msgs::MultiArrayLayout.new end if args[:data] @data = args[:data] else @data = [] end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
65 66 67 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 65 def data @data end |
#layout ⇒ Object
Returns the value of attribute layout.
65 66 67 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 65 def layout @layout end |
Class Method Details
.md5sum ⇒ Object
10 11 12 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 10 def self.md5sum "54865aa6c65be0448113a2afc6a49270" end |
.type ⇒ Object
14 15 16 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 14 def self.type "std_msgs/Int64MultiArray" end |
Instance Method Details
#_get_types ⇒ String
internal API method
93 94 95 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 93 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
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 123 def deserialize(str) begin if @layout == nil @layout = Std_msgs::MultiArrayLayout.new end end_point = 0 start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) @layout.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)]) @layout.dim.push(val1) end start = end_point end_point += ROS::Struct::calc_size('L') (@layout.data_offset,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "q#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @data = str[start..(end_point-1)].unpack(pattern) return self rescue => exception raise "message DeserializationError: #{exception}" #most likely buffer underfill end end |
#has_header? ⇒ Boolean
18 19 20 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 18 def has_header? false end |
#message_definition ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 22 def "# Please look at the MultiArrayLayout message definition for # documentation on all multiarrays. MultiArrayLayout layout # specification of data layout int64[] data # array of data ================================================================================ MSG: std_msgs/MultiArrayLayout # 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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/std_msgs/Int64MultiArray.rb', line 99 def serialize(buff) begin length = @layout.dim.length buff.write(@@struct_L.pack(length)) for val1 in @layout.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(@layout.data_offset)) length = @data.length buff.write(@@struct_L.pack(length)) pattern = "q#{length}" buff.write(*@data.pack(pattern)) rescue => exception raise "some erro in serialize: #{exception}" end end |