Class: Sensor_msgs::LaserScan
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Sensor_msgs::LaserScan
- Defined in:
- lib/sensor_msgs/LaserScan.rb
Constant Summary collapse
- @@struct_f7 =
::ROS::Struct.new("f7")
- @@struct_L3 =
::ROS::Struct.new("L3")
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['Header','float32','float32','float32','float32','float32','float32','float32','float32[]','float32[]']
Instance Attribute Summary collapse
-
#angle_increment ⇒ Object
Returns the value of attribute angle_increment.
-
#angle_max ⇒ Object
Returns the value of attribute angle_max.
-
#angle_min ⇒ Object
Returns the value of attribute angle_min.
-
#header ⇒ Object
Returns the value of attribute header.
-
#intensities ⇒ Object
Returns the value of attribute intensities.
-
#range_max ⇒ Object
Returns the value of attribute range_max.
-
#range_min ⇒ Object
Returns the value of attribute range_min.
-
#ranges ⇒ Object
Returns the value of attribute ranges.
-
#scan_time ⇒ Object
Returns the value of attribute scan_time.
-
#time_increment ⇒ Object
Returns the value of attribute time_increment.
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 = {}) ⇒ LaserScan
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ LaserScan
Constructor. You can set the default values using keyword operators.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/sensor_msgs/LaserScan.rb', line 93 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[:angle_min] @angle_min = args[:angle_min] else @angle_min = 0.0 end if args[:angle_max] @angle_max = args[:angle_max] else @angle_max = 0.0 end if args[:angle_increment] @angle_increment = args[:angle_increment] else @angle_increment = 0.0 end if args[:time_increment] @time_increment = args[:time_increment] else @time_increment = 0.0 end if args[:scan_time] @scan_time = args[:scan_time] else @scan_time = 0.0 end if args[:range_min] @range_min = args[:range_min] else @range_min = 0.0 end if args[:range_max] @range_max = args[:range_max] else @range_max = 0.0 end if args[:ranges] @ranges = args[:ranges] else @ranges = [] end if args[:intensities] @intensities = args[:intensities] else @intensities = [] end end |
Instance Attribute Details
#angle_increment ⇒ Object
Returns the value of attribute angle_increment.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def angle_increment @angle_increment end |
#angle_max ⇒ Object
Returns the value of attribute angle_max.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def angle_max @angle_max end |
#angle_min ⇒ Object
Returns the value of attribute angle_min.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def angle_min @angle_min end |
#header ⇒ Object
Returns the value of attribute header.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def header @header end |
#intensities ⇒ Object
Returns the value of attribute intensities.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def intensities @intensities end |
#range_max ⇒ Object
Returns the value of attribute range_max.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def range_max @range_max end |
#range_min ⇒ Object
Returns the value of attribute range_min.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def range_min @range_min end |
#ranges ⇒ Object
Returns the value of attribute ranges.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def ranges @ranges end |
#scan_time ⇒ Object
Returns the value of attribute scan_time.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def scan_time @scan_time end |
#time_increment ⇒ Object
Returns the value of attribute time_increment.
72 73 74 |
# File 'lib/sensor_msgs/LaserScan.rb', line 72 def time_increment @time_increment end |
Class Method Details
.md5sum ⇒ Object
9 10 11 |
# File 'lib/sensor_msgs/LaserScan.rb', line 9 def self.md5sum "90c7ef2dc6895d81024acba2ac42f369" end |
.type ⇒ Object
13 14 15 |
# File 'lib/sensor_msgs/LaserScan.rb', line 13 def self.type "sensor_msgs/LaserScan" end |
Instance Method Details
#_get_types ⇒ String
internal API method
149 150 151 |
# File 'lib/sensor_msgs/LaserScan.rb', line 149 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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/sensor_msgs/LaserScan.rb', line 178 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('f7') (@angle_min, @angle_max, @angle_increment, @time_increment, @scan_time, @range_min, @range_max,) = @@struct_f7.unpack(str[start..(end_point-1)]) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "f#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @ranges = str[start..(end_point-1)].unpack(pattern) start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) pattern = "f#{length}" start = end_point end_point += ROS::Struct::calc_size("#{pattern}") @intensities = str[start..(end_point-1)].unpack(pattern) return self rescue => exception raise "message DeserializationError: #{exception}" #most likely buffer underfill end end |
#has_header? ⇒ Boolean
17 18 19 |
# File 'lib/sensor_msgs/LaserScan.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 70 71 |
# File 'lib/sensor_msgs/LaserScan.rb', line 21 def "# Single scan from a planar laser range-finder # # If you have another ranging device with different behavior (e.g. a sonar # array), please find or create a different message, since applications # will make fairly laser-specific assumptions about this data Header header # timestamp in the header is the acquisition time of # the first ray in the scan. # # in frame frame_id, angles are measured around # the positive Z axis (counterclockwise, if Z is up) # with zero angle being forward along the x axis float32 angle_min # start angle of the scan [rad] float32 angle_max # end angle of the scan [rad] float32 angle_increment # angular distance between measurements [rad] float32 time_increment # time between measurements [seconds] - if your scanner # is moving, this will be used in interpolating position # of 3d points float32 scan_time # time between scans [seconds] float32 range_min # minimum range value [m] float32 range_max # maximum range value [m] float32[] ranges # range data [m] (Note: values < range_min or > range_max should be discarded) float32[] intensities # intensity data [device-specific units]. If your # device does not provide intensities, please leave # the array empty. ================================================================================ 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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/sensor_msgs/LaserScan.rb', line 155 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_f7.pack(@angle_min, @angle_max, @angle_increment, @time_increment, @scan_time, @range_min, @range_max)) length = @ranges.length buff.write(@@struct_L.pack(length)) pattern = "f#{length}" buff.write(*@ranges.pack(pattern)) length = @intensities.length buff.write(@@struct_L.pack(length)) pattern = "f#{length}" buff.write(*@intensities.pack(pattern)) rescue => exception raise "some erro in serialize: #{exception}" end end |