Class: Stereo_msgs::DisparityImage

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/stereo_msgs/DisparityImage.rb

Constant Summary collapse

@@struct_f2L4Cf3 =
::ROS::Struct.new("f2L4Cf3")
@@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','sensor_msgs/Image','float32','float32','sensor_msgs/RegionOfInterest','float32','float32','float32']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ DisparityImage

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :header (Header)

    initialize value

  • :image (sensor_msgs/Image)

    initialize value

  • :f (float32)

    initialize value

  • :T (float32)

    initialize value

  • :valid_window (sensor_msgs/RegionOfInterest)

    initialize value

  • :min_disparity (float32)

    initialize value

  • :max_disparity (float32)

    initialize value

  • :delta_d (float32)

    initialize value



147
148
149
150
151
152
153
154
155
156
157
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
# File 'lib/stereo_msgs/DisparityImage.rb', line 147

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[:image]
    @image = args[:image]
  else
    @image = Sensor_msgs::Image.new
  end
  if args[:f]
    @f = args[:f]
  else
    @f = 0.0
  end
  if args[:T]
    @T = args[:T]
  else
    @T = 0.0
  end
  if args[:valid_window]
    @valid_window = args[:valid_window]
  else
    @valid_window = Sensor_msgs::RegionOfInterest.new
  end
  if args[:min_disparity]
    @min_disparity = args[:min_disparity]
  else
    @min_disparity = 0.0
  end
  if args[:max_disparity]
    @max_disparity = args[:max_disparity]
  else
    @max_disparity = 0.0
  end
  if args[:delta_d]
    @delta_d = args[:delta_d]
  else
    @delta_d = 0.0
  end
end

Instance Attribute Details

#delta_dObject

Returns the value of attribute delta_d.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def delta_d
  @delta_d
end

#fObject

Returns the value of attribute f.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def f
  @f
end

#headerObject

Returns the value of attribute header.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def header
  @header
end

#imageObject

Returns the value of attribute image.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def image
  @image
end

#max_disparityObject

Returns the value of attribute max_disparity.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def max_disparity
  @max_disparity
end

#min_disparityObject

Returns the value of attribute min_disparity.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def min_disparity
  @min_disparity
end

#TObject

Returns the value of attribute T.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def T
  @T
end

#valid_windowObject

Returns the value of attribute valid_window.



126
127
128
# File 'lib/stereo_msgs/DisparityImage.rb', line 126

def valid_window
  @valid_window
end

Class Method Details

.md5sumObject



11
12
13
# File 'lib/stereo_msgs/DisparityImage.rb', line 11

def self.md5sum
  "04a177815f75271039fa21f16acad8c9"
end

.typeObject



15
16
17
# File 'lib/stereo_msgs/DisparityImage.rb', line 15

def self.type
  "stereo_msgs/DisparityImage"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



193
194
195
# File 'lib/stereo_msgs/DisparityImage.rb', line 193

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


226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/stereo_msgs/DisparityImage.rb', line 226

def deserialize(str)

  begin
    if @header == nil
      @header = Std_msgs::Header.new
    end
    if @image == nil
      @image = Sensor_msgs::Image.new
    end
    if @valid_window == nil
      @valid_window = Sensor_msgs::RegionOfInterest.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('L3')
    (@image.header.seq, @image.header.stamp.secs, @image.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
    @image.header.frame_id = str[start..(end_point-1)]
    start = end_point
    end_point += ROS::Struct::calc_size('L2')
    (@image.height, @image.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
    @image.encoding = str[start..(end_point-1)]
    start = end_point
    end_point += ROS::Struct::calc_size('CL')
    (@image.is_bigendian, @image.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
    @image.data = str[start..(end_point-1)]
    start = end_point
    end_point += ROS::Struct::calc_size('f2L4Cf3')
    (@f, @T, @valid_window.x_offset, @valid_window.y_offset, @valid_window.height, @valid_window.width, @valid_window.do_rectify, @min_disparity, @max_disparity, @delta_d,) = @@struct_f2L4Cf3.unpack(str[start..(end_point-1)])
    @valid_window.do_rectify = bool(@valid_window.do_rectify)
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/stereo_msgs/DisparityImage.rb', line 19

def has_header?
  true
end

#message_definitionObject



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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
# File 'lib/stereo_msgs/DisparityImage.rb', line 23

def message_definition
  "# Separate header for compatibility with current TimeSynchronizer.
# Likely to be removed in a later release, use image.header instead.
Header header

# Floating point disparity image. The disparities are pre-adjusted for any
# x-offset between the principal points of the two cameras (in the case
# that they are verged). That is: d = x_l - x_r - (cx_l - cx_r)
sensor_msgs/Image image

# Stereo geometry. For disparity d, the depth from the camera is Z = fT/d.
float32 f # Focal length, pixels
float32 T # Baseline, world units

# Subwindow of (potentially) valid disparity values.
sensor_msgs/RegionOfInterest valid_window

# The range of disparities searched.
# In the disparity image, any disparity less than min_disparity is invalid.
# The disparity search range defines the horopter, or 3D volume that the
# stereo algorithm can \"see\". Points with Z outside of:
#     Z_min = fT / max_disparity
#     Z_max = fT / min_disparity
# could not be found.
float32 min_disparity
float32 max_disparity

# Smallest allowed disparity increment. The smallest achievable depth range
# resolution is delta_Z = (Z^2/fT)*delta_d.
float32 delta_d

================================================================================
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

================================================================================
MSG: sensor_msgs/Image
# 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: sensor_msgs/RegionOfInterest
# This message is used to specify a region of interest within an image.
#
# When used to specify the ROI setting of the camera when the image was
# taken, the height and width fields should either match the height and
# width fields for the associated image; or height = width = 0
# indicates that the full resolution image was captured.

uint32 x_offset  # Leftmost pixel of the ROI
               # (0 if the ROI includes the left edge of the image)
uint32 y_offset  # Topmost pixel of the ROI
               # (0 if the ROI includes the top edge of the image)
uint32 height    # Height of ROI
uint32 width     # Width of ROI

# True if a distinct rectified ROI should be calculated from the \"raw\"
# ROI in this message. Typically this should be False if the full image
# is captured (ROI not used), and True if a subwindow is captured (ROI
# used).
bool do_rectify

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/stereo_msgs/DisparityImage.rb', line 199

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_L3.pack(@image.header.seq, @image.header.stamp.secs, @image.header.stamp.nsecs))
    _x = @image.header.frame_id
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_L2.pack(@image.height, @image.width))
    _x = @image.encoding
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_CL.pack(@image.is_bigendian, @image.step))
    _x = @image.data
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_f2L4Cf3.pack(@f, @T, @valid_window.x_offset, @valid_window.y_offset, @valid_window.height, @valid_window.width, @valid_window.do_rectify, @min_disparity, @max_disparity, @delta_d))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end