Module: Rclrb::Fields

Defined in:
lib/rclrb/fields.rb

Overview

This module contains classes used to handle ROS messages. The content of Fields is internal API to rclrb and should not be directly called and is subject to change.

Defined Under Namespace

Classes: ArrayField, AtomicField, StringField, TimeField

Constant Summary collapse

Float64Field =
AtomicField.new "0.0", "Float64Field", :double, :get_array_of_float64, :put_array_of_float64
Float32Field =
AtomicField.new "0.0", "Float32Field", :float, :get_array_of_float32, :put_array_of_float32
ByteField =
AtomicField.new "0", "ByteField", :uint8, :get_array_of_uint8, :put_array_of_uint8
CharField =
AtomicField.new "0", "CharField", :uint8, :get_array_of_uint8, :put_array_of_uint8
BoolField =
AtomicField.new "false", "BoolField", :bool, nil, nil
Int8Field =
AtomicField.new "0", "Int8Field", :int8, :get_array_of_int8, :put_array_of_int8
Int16Field =
AtomicField.new "0", "Int16Field", :int16, :get_array_of_int16, :put_array_of_int16
Int32Field =
AtomicField.new "0", "Int32Field", :int32, :get_array_of_int32, :put_array_of_int32
Int64Field =
AtomicField.new "0", "Int64Field", :int64, :get_array_of_int64, :put_array_of_int64
Uint8Field =
AtomicField.new "0", "Uint8Field", :uint8, :get_array_of_uint8, :put_array_of_uint8
Uint16Field =
AtomicField.new "0", "Uint16Field", :uint16, :get_array_of_uint16, :put_array_of_uint16
Uint32Field =
AtomicField.new "0", "Uint32Field", :uint32, :get_array_of_uint32, :put_array_of_uint32
Uint64Field =
AtomicField.new "0", "Uint64Field", :uint64, :get_array_of_uint64, :put_array_of_uint64
AtomicFields =
{ "float64" => Float64Field,
"float32" => Float32Field,
"char" => CharField,
"byte" => ByteField,
"bool" => BoolField,
"int8" => Int8Field,
"int16" => Int16Field,
"int32" => Int32Field,
"int64" => Int64Field,
"uint8" => Uint8Field,
"uint16" => Uint16Field,
"uint32" => Uint32Field,
"uint64" => Uint64Field,
"string" => StringField,
"builtin_interfaces/Time"   => TimeField }

Class Method Summary collapse

Class Method Details

.__generic_fill_ros_message_array(array_pointer, value, field_size, &block) ⇒ Object

This function is used for building generic fill_ros_message_array function, that will write array elements one-by-one and call block to add them



17
18
19
20
21
# File 'lib/rclrb/fields.rb', line 17

def Fields.__generic_fill_ros_message_array array_pointer, value, field_size, &block
  for i in 0...value.length
    block.call array_pointer + i * field_size, value[i]
  end
end

.__generic_parse_array(data, length, field_size, &block) ⇒ Object

This function is used for building generic parse_ros_message_array function, that will read array elements one-by-one and call block to parse them



8
9
10
11
12
13
14
15
# File 'lib/rclrb/fields.rb', line 8

def Fields.__generic_parse_array data, length, field_size, &block
  array = []
  for i in 0...length
    ptr = data + i * field_size
    array.append block.call(ptr)
  end
  return array
end