Class: Roscpp_tutorials::TwoIntsResponse

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/roscpp_tutorials/TwoInts.rb

Constant Summary collapse

@@struct_q =
::ROS::Struct.new("q")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['int64']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TwoIntsResponse

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :sum (int64)

    initialize value



121
122
123
124
125
126
127
128
# File 'lib/roscpp_tutorials/TwoInts.rb', line 121

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

Instance Attribute Details

#sumObject

Returns the value of attribute sum.



110
111
112
# File 'lib/roscpp_tutorials/TwoInts.rb', line 110

def sum
  @sum
end

Class Method Details

.md5sumObject



92
93
94
# File 'lib/roscpp_tutorials/TwoInts.rb', line 92

def self.md5sum
  "b88405221c77b1878a3cbbfff53428d7"
end

.typeObject



96
97
98
# File 'lib/roscpp_tutorials/TwoInts.rb', line 96

def self.type
  "roscpp_tutorials/TwoIntsResponse"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



132
133
134
# File 'lib/roscpp_tutorials/TwoInts.rb', line 132

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


149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/roscpp_tutorials/TwoInts.rb', line 149

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('q')
    (@sum,) = @@struct_q.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)


100
101
102
# File 'lib/roscpp_tutorials/TwoInts.rb', line 100

def has_header?
  false
end

#message_definitionObject



104
105
106
107
108
109
# File 'lib/roscpp_tutorials/TwoInts.rb', line 104

def message_definition
  "int64 sum


"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



138
139
140
141
142
143
144
145
# File 'lib/roscpp_tutorials/TwoInts.rb', line 138

def serialize(buff)
  begin
    buff.write(@@struct_q.pack(@sum))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end