Class: Sensor_msgs::Image
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Sensor_msgs::Image
- Defined in:
- lib/sensor_msgs/Image.rb
Constant Summary collapse
- @@struct_L3 =
::ROS::Struct.new("L3")
- @@struct_L2 =
::ROS::Struct.new("L2")
- @@struct_CL =
::ROS::Struct.new("CL")
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['Header','uint32','uint32','string','uint8','uint32','uint8[]']
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#header ⇒ Object
Returns the value of attribute header.
-
#height ⇒ Object
Returns the value of attribute height.
-
#is_bigendian ⇒ Object
Returns the value of attribute is_bigendian.
-
#step ⇒ Object
Returns the value of attribute step.
-
#width ⇒ Object
Returns the value of attribute width.
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 = {}) ⇒ Image
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ Image
Constructor. You can set the default values using keyword operators.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/sensor_msgs/Image.rb', line 89 def initialize(args={}) # message fields cannot be None, assign default values for those that are if args[:header] @header = args[:header] else @header = Std_msgs::Header.new end if args[:height] @height = args[:height] else @height = 0 end if args[:width] @width = args[:width] else @width = 0 end if args[:encoding] @encoding = args[:encoding] else @encoding = '' end if args[:is_bigendian] @is_bigendian = args[:is_bigendian] else @is_bigendian = 0 end if args[:step] @step = args[:step] else @step = 0 end if args[:data] @data = args[:data] else @data = '' end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def data @data end |
#encoding ⇒ Object
Returns the value of attribute encoding.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def encoding @encoding end |
#header ⇒ Object
Returns the value of attribute header.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def header @header end |
#height ⇒ Object
Returns the value of attribute height.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def height @height end |
#is_bigendian ⇒ Object
Returns the value of attribute is_bigendian.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def is_bigendian @is_bigendian end |
#step ⇒ Object
Returns the value of attribute step.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def step @step end |
#width ⇒ Object
Returns the value of attribute width.
70 71 72 |
# File 'lib/sensor_msgs/Image.rb', line 70 def width @width end |
Class Method Details
.md5sum ⇒ Object
9 10 11 |
# File 'lib/sensor_msgs/Image.rb', line 9 def self.md5sum "060021388200f6f0f447d0fcd9c64743" end |
.type ⇒ Object
13 14 15 |
# File 'lib/sensor_msgs/Image.rb', line 13 def self.type "sensor_msgs/Image" end |
Instance Method Details
#_get_types ⇒ String
internal API method
130 131 132 |
# File 'lib/sensor_msgs/Image.rb', line 130 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
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/sensor_msgs/Image.rb', line 158 def deserialize(str) begin if @header == nil @header = Std_msgs::Header.new end end_point = 0 start = end_point end_point += ROS::Struct::calc_size('L3') (@header.seq, @header.stamp.secs, @header.stamp.nsecs,) = @@struct_L3.unpack(str[start..(end_point-1)]) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length @header.frame_id = str[start..(end_point-1)] start = end_point end_point += ROS::Struct::calc_size('L2') (@height, @width,) = @@struct_L2.unpack(str[start..(end_point-1)]) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length @encoding = str[start..(end_point-1)] start = end_point end_point += ROS::Struct::calc_size('CL') (@is_bigendian, @step,) = @@struct_CL.unpack(str[start..(end_point-1)]) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length @data = 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/sensor_msgs/Image.rb', line 17 def has_header? true 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sensor_msgs/Image.rb', line 21 def "# This message contains an uncompressed image # (0, 0) is at top-left corner of image # Header header # Header timestamp should be acquisition time of image # Header frame_id should be optical frame of camera # origin of frame should be optical center of cameara # +x should point to the right in the image # +y should point down in the image # +z should point into to plane of the image # If the frame_id here and the frame_id of the CameraInfo # message associated with the image conflict # the behavior is undefined uint32 height # image height, that is, number of rows uint32 width # image width, that is, number of columns # The legal values for encoding are in file src/image_encodings.cpp # If you want to standardize a new string format, join # [email protected] and send an email proposing a new encoding. string encoding # Encoding of pixels -- channel meaning, ordering, size # taken from the list of strings in src/image_encodings.cpp uint8 is_bigendian # is this data bigendian? uint32 step # Full row length in bytes uint8[] data # actual matrix data, size is (step * rows) ================================================================================ MSG: std_msgs/Header # Standard metadata for higher-level stamped data types. # This is generally used to communicate timestamped data # in a particular coordinate frame. # # sequence ID: consecutively increasing ID uint32 seq #Two-integer timestamp that is expressed as: # * stamp.secs: seconds (stamp_secs) since epoch # * stamp.nsecs: nanoseconds since stamp_secs # time-handling sugar is provided by the client library time stamp #Frame this data is associated with # 0: no frame # 1: global frame string frame_id " end |
#serialize(buff) ⇒ Object
serialize message into buffer
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/sensor_msgs/Image.rb', line 136 def serialize(buff) begin buff.write(@@struct_L3.pack(@header.seq, @header.stamp.secs, @header.stamp.nsecs)) _x = @header.frame_id length = _x.length buff.write([length, _x].pack("La#{length}")) buff.write(@@struct_L2.pack(@height, @width)) _x = @encoding length = _x.length buff.write([length, _x].pack("La#{length}")) buff.write(@@struct_CL.pack(@is_bigendian, @step)) _x = @data length = _x.length buff.write([length, _x].pack("La#{length}")) rescue => exception raise "some erro in serialize: #{exception}" end end |