Class: Geometry_msgs::Twist

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

Constant Summary collapse

@@struct_d6 =
::ROS::Struct.new("d6")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['geometry_msgs/Vector3','geometry_msgs/Vector3']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Twist

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :linear (geometry_msgs/Vector3)

    initialize value

  • :angular (geometry_msgs/Vector3)

    initialize value



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/geometry_msgs/Twist.rb', line 47

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

Instance Attribute Details

#angularObject

Returns the value of attribute angular.



35
36
37
# File 'lib/geometry_msgs/Twist.rb', line 35

def angular
  @angular
end

#linearObject

Returns the value of attribute linear.



35
36
37
# File 'lib/geometry_msgs/Twist.rb', line 35

def linear
  @linear
end

Class Method Details

.md5sumObject



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

def self.md5sum
  "9f195f881246fdfa2798d1d3eebca84a"
end

.typeObject



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

def self.type
  "geometry_msgs/Twist"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



63
64
65
# File 'lib/geometry_msgs/Twist.rb', line 63

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


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/geometry_msgs/Twist.rb', line 80

def deserialize(str)

  begin
    if @linear == nil
      @linear = Geometry_msgs::Vector3.new
    end
    if @angular == nil
      @angular = Geometry_msgs::Vector3.new
    end
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('d6')
    (@linear.x, @linear.y, @linear.z, @angular.x, @angular.y, @angular.z,) = @@struct_d6.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)


17
18
19
# File 'lib/geometry_msgs/Twist.rb', line 17

def has_header?
  false
end

#message_definitionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/geometry_msgs/Twist.rb', line 21

def message_definition
  "# This expresses velocity in free space broken into it's linear and angular parts. 
Vector3  linear
Vector3  angular

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

float64 x
float64 y
float64 z
"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



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

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

  end
end