Class: Tf::TfMessage

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/tf/tfMessage.rb

Constant Summary collapse

@@struct_d4 =
::ROS::Struct.new("d4")
@@struct_L2 =
::ROS::Struct.new("L2")
@@struct_d3 =
::ROS::Struct.new("d3")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['geometry_msgs/TransformStamped[]']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TfMessage

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :transforms (geometry_msgs/TransformStamped[])

    initialize value



97
98
99
100
101
102
103
104
# File 'lib/tf/tfMessage.rb', line 97

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

Instance Attribute Details

#transformsObject

Returns the value of attribute transforms.



84
85
86
# File 'lib/tf/tfMessage.rb', line 84

def transforms
  @transforms
end

Class Method Details

.md5sumObject



13
14
15
# File 'lib/tf/tfMessage.rb', line 13

def self.md5sum
  "94810edda583a504dfda3829e70d7eec"
end

.typeObject



17
18
19
# File 'lib/tf/tfMessage.rb', line 17

def self.type
  "tf/tfMessage"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



108
109
110
# File 'lib/tf/tfMessage.rb', line 108

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


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/tf/tfMessage.rb', line 146

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    @transforms = []
    length.times do
      val1 = Geometry_msgs::TransformStamped.new
      _v148 = val1.header
      start = end_point
      end_point += ROS::Struct::calc_size('L')
      (_v148.seq,) = @@struct_L.unpack(str[start..(end_point-1)])
      _v149 = _v148.stamp
      _x = _v149
      start = end_point
      end_point += ROS::Struct::calc_size('L2')
      (_x.secs, _x.nsecs,) = @@struct_L2.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
      _v148.frame_id = 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
      val1.child_frame_id = str[start..(end_point-1)]
      _v150 = val1.transform
      _v151 = _v150.translation
      _x = _v151
      start = end_point
      end_point += ROS::Struct::calc_size('d3')
      (_x.x, _x.y, _x.z,) = @@struct_d3.unpack(str[start..(end_point-1)])
      _v152 = _v150.rotation
      _x = _v152
      start = end_point
      end_point += ROS::Struct::calc_size('d4')
      (_x.x, _x.y, _x.z, _x.w,) = @@struct_d4.unpack(str[start..(end_point-1)])
      @transforms.push(val1)
    end
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/tf/tfMessage.rb', line 21

def has_header?
  false
end

#message_definitionObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/tf/tfMessage.rb', line 25

def message_definition
  "geometry_msgs/TransformStamped[] transforms

================================================================================
MSG: geometry_msgs/TransformStamped
# This expresses a transform from coordinate frame header.frame_id
# to the coordinate frame child_frame_id
#
# This message is mostly used by the 
# <a href=\"http://www.ros.org/wiki/tf\">tf</a> package. 
# See it's documentation for more information.

Header header
string child_frame_id # the frame id of the child frame
Transform transform

================================================================================
MSG: std_msgs/Header
# 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

================================================================================
MSG: geometry_msgs/Transform
# This represents the transform between two coordinate frames in free space.

Vector3 translation
Quaternion rotation

================================================================================
MSG: geometry_msgs/Vector3
# This represents a vector in free space. 

float64 x
float64 y
float64 z
================================================================================
MSG: geometry_msgs/Quaternion
# This represents an orientation in free space in quaternion form.

float64 x
float64 y
float64 z
float64 w

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/tf/tfMessage.rb', line 114

def serialize(buff)
  begin
    length = @transforms.length
    buff.write(@@struct_L.pack(length))
    for val1 in @transforms
      _v143 = val1.header
      buff.write(@@struct_L.pack(_v143.seq))
      _v144 = _v143.stamp
      _x = _v144
      buff.write(@@struct_L2.pack(_x.secs, _x.nsecs))
      _x = _v143.frame_id
      length = _x.length
      buff.write([length, _x].pack("La#{length}"))
      _x = val1.child_frame_id
      length = _x.length
      buff.write([length, _x].pack("La#{length}"))
      _v145 = val1.transform
      _v146 = _v145.translation
      _x = _v146
      buff.write(@@struct_d3.pack(_x.x, _x.y, _x.z))
      _v147 = _v145.rotation
      _x = _v147
      buff.write(@@struct_d4.pack(_x.x, _x.y, _x.z, _x.w))
    end
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end