Class: Sensor_msgs::ChannelFloat32

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

Constant Summary collapse

@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['string','float32[]']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ChannelFloat32

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :name (string)

    initialize value

  • :values (float32[])

    initialize value



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 59

def initialize(args={})
  # message fields cannot be None, assign default values for those that are
  if args[:name]
    @name = args[:name]
  else
    @name = ''
  end
  if args[:values]
    @values = args[:values]
  else
    @values = []
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



48
49
50
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 48

def name
  @name
end

#valuesObject

Returns the value of attribute values.



48
49
50
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 48

def values
  @values
end

Class Method Details

.md5sumObject



8
9
10
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 8

def self.md5sum
  "3d40139cdd33dfedcb71ffeeeb42ae7f"
end

.typeObject



12
13
14
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 12

def self.type
  "sensor_msgs/ChannelFloat32"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



75
76
77
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 75

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


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 98

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    start = end_point
    end_point += length
    @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}")
    @values = str[start..(end_point-1)].unpack(pattern)
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 16

def has_header?
  false
end

#message_definitionObject



20
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
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 20

def message_definition
  "# 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

Parameters:

  • buff (IO)

    buffer



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/sensor_msgs/ChannelFloat32.rb', line 81

def serialize(buff)
  begin
    _x = @name
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    length = @values.length
    buff.write(@@struct_L.pack(length))
    pattern = "f#{length}"
    buff.write(*@values.pack(pattern))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end