Class: Sensor_msgs::PointCloud
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Sensor_msgs::PointCloud
- Defined in:
- lib/sensor_msgs/PointCloud.rb
Constant Summary collapse
- @@struct_L3 =
::ROS::Struct.new("L3")
- @@struct_f3 =
::ROS::Struct.new("f3")
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['Header','geometry_msgs/Point32[]','sensor_msgs/ChannelFloat32[]']
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#header ⇒ Object
Returns the value of attribute header.
-
#points ⇒ Object
Returns the value of attribute points.
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 = {}) ⇒ PointCloud
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ PointCloud
Constructor. You can set the default values using keyword operators.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/sensor_msgs/PointCloud.rb', line 113 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[:points] @points = args[:points] else @points = [] end if args[:channels] @channels = args[:channels] else @channels = [] end end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels.
99 100 101 |
# File 'lib/sensor_msgs/PointCloud.rb', line 99 def channels @channels end |
#header ⇒ Object
Returns the value of attribute header.
99 100 101 |
# File 'lib/sensor_msgs/PointCloud.rb', line 99 def header @header end |
#points ⇒ Object
Returns the value of attribute points.
99 100 101 |
# File 'lib/sensor_msgs/PointCloud.rb', line 99 def points @points end |
Class Method Details
.md5sum ⇒ Object
11 12 13 |
# File 'lib/sensor_msgs/PointCloud.rb', line 11 def self.md5sum "d8e9c3f5afbdd8a130fd1d2763945fca" end |
.type ⇒ Object
15 16 17 |
# File 'lib/sensor_msgs/PointCloud.rb', line 15 def self.type "sensor_msgs/PointCloud" end |
Instance Method Details
#_get_types ⇒ String
internal API method
134 135 136 |
# File 'lib/sensor_msgs/PointCloud.rb', line 134 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
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/sensor_msgs/PointCloud.rb', line 171 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 += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) @points = [] length.times do val1 = Geometry_msgs::Point32.new _x = val1 start = end_point end_point += ROS::Struct::calc_size('f3') (_x.x, _x.y, _x.z,) = @@struct_f3.unpack(str[start..(end_point-1)]) @points.push(val1) end start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) @channels = [] length.times do val1 = Sensor_msgs::ChannelFloat32.new start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length val1.name = 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}") val1.values = str[start..(end_point-1)].unpack(pattern) @channels.push(val1) end return self rescue => exception raise "message DeserializationError: #{exception}" #most likely buffer underfill end end |
#has_header? ⇒ Boolean
19 20 21 |
# File 'lib/sensor_msgs/PointCloud.rb', line 19 def has_header? true end |
#message_definition ⇒ Object
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 |
# File 'lib/sensor_msgs/PointCloud.rb', line 23 def "# This message holds a collection of 3d points, plus optional additional # information about each point. # Time of sensor data acquisition, coordinate frame ID. Header header # Array of 3d points. Each Point32 should be interpreted as a 3d point # in the frame given in the header. geometry_msgs/Point32[] points # Each channel should have the same number of elements as points array, # and the data in each channel should correspond 1:1 with each point. # Channel names in common practice are listed in ChannelFloat32.msg. ChannelFloat32[] channels ================================================================================ 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: geometry_msgs/Point32 # This contains the position of a point in free space(with 32 bits of precision). # It is recommeded to use Point wherever possible instead of Point32. # # This recommendation is to promote interoperability. # # This message is designed to take up less space when sending # lots of points at once, as in the case of a PointCloud. float32 x float32 y float32 z ================================================================================ MSG: sensor_msgs/ChannelFloat32 # This message is used by the PointCloud message to hold optional data # associated with each point in the cloud. The length of the values # array should be the same as the length of the points array in the # PointCloud, and each value should be associated with the corresponding # point. # Channel names in existing practice include: # \"u\", \"v\" - row and column (respectively) in the left stereo image. # This is opposite to usual conventions but remains for # historical reasons. The newer PointCloud2 message has no # such problem. # \"rgb\" - For point clouds produced by color stereo cameras. uint8 # (R,G,B) values packed into the least significant 24 bits, # in order. # \"intensity\" - laser or pixel intensity. # \"distance\" # The channel name should give semantics of the channel (e.g. # \"intensity\" instead of \"value\"). string name # The values array should be 1-1 with the elements of the associated # PointCloud. float32[] values " end |
#serialize(buff) ⇒ Object
serialize message into buffer
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/sensor_msgs/PointCloud.rb', line 140 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}")) length = @points.length buff.write(@@struct_L.pack(length)) for val1 in @points _x = val1 buff.write(@@struct_f3.pack(_x.x, _x.y, _x.z)) end length = @channels.length buff.write(@@struct_L.pack(length)) for val1 in @channels _x = val1.name length = _x.length buff.write([length, _x].pack("La#{length}")) length = val1.values.length buff.write(@@struct_L.pack(length)) pattern = "f#{length}" buff.write(*val1.values.pack(pattern)) end rescue => exception raise "some erro in serialize: #{exception}" end end |