Class: Sensor_msgs::PointField

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

Constant Summary collapse

INT8 =

Pseudo-constants

1
UINT8 =
2
INT16 =
3
UINT16 =
4
INT32 =
5
UINT32 =
6
FLOAT32 =
7
FLOAT64 =
8
@@struct_LCL =
::ROS::Struct.new("LCL")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['string','uint32','uint8','uint32']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PointField

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

  • :offset (uint32)

    initialize value

  • :datatype (uint8)

    initialize value

  • :count (uint32)

    initialize value



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/sensor_msgs/PointField.rb', line 63

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[:offset]
    @offset = args[:offset]
  else
    @offset = 0
  end
  if args[:datatype]
    @datatype = args[:datatype]
  else
    @datatype = 0
  end
  if args[:count]
    @count = args[:count]
  else
    @count = 0
  end
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



49
50
51
# File 'lib/sensor_msgs/PointField.rb', line 49

def count
  @count
end

#datatypeObject

Returns the value of attribute datatype.



49
50
51
# File 'lib/sensor_msgs/PointField.rb', line 49

def datatype
  @datatype
end

#nameObject

Returns the value of attribute name.



49
50
51
# File 'lib/sensor_msgs/PointField.rb', line 49

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



49
50
51
# File 'lib/sensor_msgs/PointField.rb', line 49

def offset
  @offset
end

Class Method Details

.md5sumObject



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

def self.md5sum
  "268eacb2962780ceac86cbd17e328150"
end

.typeObject



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

def self.type
  "sensor_msgs/PointField"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



89
90
91
# File 'lib/sensor_msgs/PointField.rb', line 89

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


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/sensor_msgs/PointField.rb', line 109

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 += ROS::Struct::calc_size('LCL')
    (@offset, @datatype, @count,) = @@struct_LCL.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)


16
17
18
# File 'lib/sensor_msgs/PointField.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
# File 'lib/sensor_msgs/PointField.rb', line 20

def message_definition
  "# This message holds the description of one point entry in the
# PointCloud2 message format.
uint8 INT8    = 1
uint8 UINT8   = 2
uint8 INT16   = 3
uint8 UINT16  = 4
uint8 INT32   = 5
uint8 UINT32  = 6
uint8 FLOAT32 = 7
uint8 FLOAT64 = 8

string name      # Name of field
uint32 offset    # Offset from start of point struct
uint8  datatype  # Datatype enumeration, see above
uint32 count     # How many elements in the field

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/sensor_msgs/PointField.rb', line 95

def serialize(buff)
  begin
    _x = @name
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
    buff.write(@@struct_LCL.pack(@offset, @datatype, @count))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end