Class: Geometry_msgs::Pose2D

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

Constant Summary collapse

@@struct_d3 =
::ROS::Struct.new("d3")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['float64','float64','float64']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Pose2D

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :x (float64)

    initialize value

  • :y (float64)

    initialize value

  • :theta (float64)

    initialize value



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/geometry_msgs/Pose2D.rb', line 41

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

Instance Attribute Details

#thetaObject

Returns the value of attribute theta.



28
29
30
# File 'lib/geometry_msgs/Pose2D.rb', line 28

def theta
  @theta
end

#xObject

Returns the value of attribute x.



28
29
30
# File 'lib/geometry_msgs/Pose2D.rb', line 28

def x
  @x
end

#yObject

Returns the value of attribute y.



28
29
30
# File 'lib/geometry_msgs/Pose2D.rb', line 28

def y
  @y
end

Class Method Details

.md5sumObject



8
9
10
# File 'lib/geometry_msgs/Pose2D.rb', line 8

def self.md5sum
  "938fa65709584ad8e77d238529be13b8"
end

.typeObject



12
13
14
# File 'lib/geometry_msgs/Pose2D.rb', line 12

def self.type
  "geometry_msgs/Pose2D"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



62
63
64
# File 'lib/geometry_msgs/Pose2D.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


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

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('d3')
    (@x, @y, @theta,) = @@struct_d3.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)


16
17
18
# File 'lib/geometry_msgs/Pose2D.rb', line 16

def has_header?
  false
end

#message_definitionObject



20
21
22
23
24
25
26
27
# File 'lib/geometry_msgs/Pose2D.rb', line 20

def message_definition
  "# This expresses a position and orientation on a 2D manifold.

float64 x
float64 y
float64 theta
"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



68
69
70
71
72
73
74
75
# File 'lib/geometry_msgs/Pose2D.rb', line 68

def serialize(buff)
  begin
    buff.write(@@struct_d3.pack(@x, @y, @theta))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end