Class: Pr2_controllers_msgs::Pr2GripperCommand

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/pr2_controllers_msgs/Pr2GripperCommand.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Pr2GripperCommand

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :position (float64)

    initialize value

  • :max_effort (float64)

    initialize value



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 38

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

Instance Attribute Details

#max_effortObject

Returns the value of attribute max_effort.



26
27
28
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 26

def max_effort
  @max_effort
end

#positionObject

Returns the value of attribute position.



26
27
28
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 26

def position
  @position
end

Class Method Details

.md5sumObject



8
9
10
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 8

def self.md5sum
  "680acaff79486f017132a7f198d40f08"
end

.typeObject



12
13
14
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 12

def self.type
  "pr2_controllers_msgs/Pr2GripperCommand"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



54
55
56
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 54

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


71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 71

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('d2')
    (@position, @max_effort,) = @@struct_d2.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/pr2_controllers_msgs/Pr2GripperCommand.rb', line 16

def has_header?
  false
end

#message_definitionObject



20
21
22
23
24
25
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 20

def message_definition
  "float64 position
float64 max_effort

"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



60
61
62
63
64
65
66
67
# File 'lib/pr2_controllers_msgs/Pr2GripperCommand.rb', line 60

def serialize(buff)
  begin
    buff.write(@@struct_d2.pack(@position, @max_effort))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end