Class: Sensor_msgs::Range

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/sensor_msgs/Range.rb

Constant Summary collapse

ULTRASOUND =

Pseudo-constants

0
INFRARED =
1
@@struct_L3 =
::ROS::Struct.new("L3")
@@struct_Cf4 =
::ROS::Struct.new("Cf4")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['Header','uint8','float32','float32','float32','float32']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Range

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

  • :radiation_type (uint8)

    initialize value

  • :field_of_view (float32)

    initialize value

  • :min_range (float32)

    initialize value

  • :max_range (float32)

    initialize value

  • :range (float32)

    initialize value



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/Range.rb', line 94

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[:radiation_type]
    @radiation_type = args[:radiation_type]
  else
    @radiation_type = 0
  end
  if args[:field_of_view]
    @field_of_view = args[:field_of_view]
  else
    @field_of_view = 0.0
  end
  if args[:min_range]
    @min_range = args[:min_range]
  else
    @min_range = 0.0
  end
  if args[:max_range]
    @max_range = args[:max_range]
  else
    @max_range = 0.0
  end
  if args[:range]
    @range = args[:range]
  else
    @range = 0.0
  end
end

Instance Attribute Details

#field_of_viewObject

Returns the value of attribute field_of_view.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def field_of_view
  @field_of_view
end

#headerObject

Returns the value of attribute header.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def header
  @header
end

#max_rangeObject

Returns the value of attribute max_range.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def max_range
  @max_range
end

#min_rangeObject

Returns the value of attribute min_range.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def min_range
  @min_range
end

#radiation_typeObject

Returns the value of attribute radiation_type.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def radiation_type
  @radiation_type
end

#rangeObject

Returns the value of attribute range.



77
78
79
# File 'lib/sensor_msgs/Range.rb', line 77

def range
  @range
end

Class Method Details

.md5sumObject



9
10
11
# File 'lib/sensor_msgs/Range.rb', line 9

def self.md5sum
  "c005c34273dc426c67a020a87bc24148"
end

.typeObject



13
14
15
# File 'lib/sensor_msgs/Range.rb', line 13

def self.type
  "sensor_msgs/Range"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



130
131
132
# File 'lib/sensor_msgs/Range.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


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/sensor_msgs/Range.rb', line 151

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('Cf4')
    (@radiation_type, @field_of_view, @min_range, @max_range, @range,) = @@struct_Cf4.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/sensor_msgs/Range.rb', line 17

def has_header?
  true
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sensor_msgs/Range.rb', line 21

def message_definition
  "# Single range reading from an active ranger that emits energy and reports
# one range reading that is valid along an arc at the distance measured. 
# This message is not appropriate for fixed-range obstacle detectors, 
# such as the Sharp GP2D15. This message is also not appropriate for laser 
# scanners. See the LaserScan message if you are working with a laser scanner.

Header header    	# timestamp in the header is the time the ranger
 	# returned the distance reading

# Radiation type enums
# If you want a value added to this list, send an email to the ros-users list
uint8 ULTRASOUND=0
uint8 INFRARED=1

uint8 radiation_type    # the type of radiation used by the sensor
 	# (sound, IR, etc) [enum]

float32 field_of_view   # the size of the arc that the distance reading is
 	# valid for [rad]
 	# the object causing the range reading may have
 	# been anywhere within -field_of_view/2 and
 	# field_of_view/2 at the measured range. 
                      # 0 angle corresponds to the x-axis of the sensor.

float32 min_range       # minimum range value [m]
float32 max_range       # maximum range value [m]

float32 range           # range data [m]
 	# (Note: values < range_min or > range_max
 	# should be discarded)

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

Parameters:

  • buff (IO)

    buffer



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/sensor_msgs/Range.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_Cf4.pack(@radiation_type, @field_of_view, @min_range, @max_range, @range))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end