Class: Geometry_msgs::Polygon

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/geometry_msgs/Polygon.rb

Constant Summary collapse

@@struct_f3 =
::ROS::Struct.new("f3")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['geometry_msgs/Point32[]']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Polygon

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :points (geometry_msgs/Point32[])

    initialize value



51
52
53
54
55
56
57
58
# File 'lib/geometry_msgs/Polygon.rb', line 51

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

Instance Attribute Details

#pointsObject

Returns the value of attribute points.



40
41
42
# File 'lib/geometry_msgs/Polygon.rb', line 40

def points
  @points
end

Class Method Details

.md5sumObject



9
10
11
# File 'lib/geometry_msgs/Polygon.rb', line 9

def self.md5sum
  "cd60a26494a087f577976f0329fa120e"
end

.typeObject



13
14
15
# File 'lib/geometry_msgs/Polygon.rb', line 13

def self.type
  "geometry_msgs/Polygon"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



62
63
64
# File 'lib/geometry_msgs/Polygon.rb', line 62

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


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/geometry_msgs/Polygon.rb', line 84

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += 4
    (length,) = @@struct_L.unpack(str[start..(end_point-1)])
    @points = []
    length.times do
      val1 = Geometry_msgs::Point32.new
      _x = val1
      start = end_point
      end_point += ROS::Struct::calc_size('f3')
      (_x.x, _x.y, _x.z,) = @@struct_f3.unpack(str[start..(end_point-1)])
      @points.push(val1)
    end
    return self
  rescue => exception
    raise "message DeserializationError: #{exception}" #most likely buffer underfill
  end
end

#has_header?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/geometry_msgs/Polygon.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/geometry_msgs/Polygon.rb', line 21

def message_definition
  "#A specification of a polygon where the first and last points are assumed to be connected
Point32[] points

================================================================================
MSG: geometry_msgs/Point32
# This contains the position of a point in free space(with 32 bits of precision).
# It is recommeded to use Point wherever possible instead of Point32.  
# 
# This recommendation is to promote interoperability.  
#
# This message is designed to take up less space when sending
# lots of points at once, as in the case of a PointCloud.  

float32 x
float32 y
float32 z
"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/geometry_msgs/Polygon.rb', line 68

def serialize(buff)
  begin
    length = @points.length
    buff.write(@@struct_L.pack(length))
    for val1 in @points
      _x = val1
      buff.write(@@struct_f3.pack(_x.x, _x.y, _x.z))
    end
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end