Class: Std_msgs::Header

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/std_msgs/Header.rb

Constant Summary collapse

@@struct_L3 =
::ROS::Struct.new("L3")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['uint32','time','string']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Header

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :seq (uint32)

    initialize value

  • :stamp (time)

    initialize value

  • :frame_id (string)

    initialize value



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/std_msgs/Header.rb', line 53

def initialize(args={})
  # message fields cannot be None, assign default values for those that are
  if args[:seq]
    @seq = args[:seq]
  else
    @seq = 0
  end
  if args[:stamp]
    @stamp = args[:stamp]
  else
    @stamp = ROS::Time.new
  end
  if args[:frame_id]
    @frame_id = args[:frame_id]
  else
    @frame_id = ''
  end
end

Instance Attribute Details

#frame_idObject

Returns the value of attribute frame_id.



40
41
42
# File 'lib/std_msgs/Header.rb', line 40

def frame_id
  @frame_id
end

#seqObject

Returns the value of attribute seq.



40
41
42
# File 'lib/std_msgs/Header.rb', line 40

def seq
  @seq
end

#stampObject

Returns the value of attribute stamp.



40
41
42
# File 'lib/std_msgs/Header.rb', line 40

def stamp
  @stamp
end

Class Method Details

.md5sumObject



9
10
11
# File 'lib/std_msgs/Header.rb', line 9

def self.md5sum
  "2176decaecbce78abc3b96ef049fabed"
end

.typeObject



13
14
15
# File 'lib/std_msgs/Header.rb', line 13

def self.type
  "std_msgs/Header"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



74
75
76
# File 'lib/std_msgs/Header.rb', line 74

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


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/std_msgs/Header.rb', line 94

def deserialize(str)

  begin
    if @stamp == nil
      @stamp = ROS::Time.new
    end
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('L3')
    (@seq, @stamp.secs, @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
    @frame_id = str[start..(end_point-1)]
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/std_msgs/Header.rb', line 17

def has_header?
  false
end

#message_definitionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/std_msgs/Header.rb', line 21

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

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/std_msgs/Header.rb', line 80

def serialize(buff)
  begin
    buff.write(@@struct_L3.pack(@seq, @stamp.secs, @stamp.nsecs))
    _x = @frame_id
    length = _x.length
    buff.write([length, _x].pack("La#{length}"))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end