Class: Geometry_msgs::Twist
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Geometry_msgs::Twist
- 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
-
#angular ⇒ Object
Returns the value of attribute angular.
-
#linear ⇒ Object
Returns the value of attribute linear.
Class Method Summary collapse
Instance Method Summary collapse
-
#_get_types ⇒ String
internal API method.
-
#deserialize(str) ⇒ Object
unpack serialized message in str into this message instance @param [String] str: byte array of serialized message.
- #has_header? ⇒ Boolean
-
#initialize(args = {}) ⇒ Twist
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ Twist
Constructor. You can set the default values using keyword operators.
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
#angular ⇒ Object
Returns the value of attribute angular.
35 36 37 |
# File 'lib/geometry_msgs/Twist.rb', line 35 def angular @angular end |
#linear ⇒ Object
Returns the value of attribute linear.
35 36 37 |
# File 'lib/geometry_msgs/Twist.rb', line 35 def linear @linear end |
Class Method Details
.md5sum ⇒ Object
9 10 11 |
# File 'lib/geometry_msgs/Twist.rb', line 9 def self.md5sum "9f195f881246fdfa2798d1d3eebca84a" end |
.type ⇒ Object
13 14 15 |
# File 'lib/geometry_msgs/Twist.rb', line 13 def self.type "geometry_msgs/Twist" end |
Instance Method Details
#_get_types ⇒ String
internal API method
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
17 18 19 |
# File 'lib/geometry_msgs/Twist.rb', line 17 def has_header? false end |
#message_definition ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/geometry_msgs/Twist.rb', line 21 def "# 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
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 |