Class: Sensor_msgs::JoyFeedback

Inherits:
ROS::Message
  • Object
show all
Defined in:
lib/sensor_msgs/JoyFeedback.rb

Constant Summary collapse

TYPE_LED =

Pseudo-constants

0
TYPE_RUMBLE =
1
TYPE_BUZZER =
2
@@struct_C2f =
::ROS::Struct.new("C2f")
@@struct_L =
::ROS::Struct.new("L")
@@slot_types =
['uint8','uint8','float32']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ JoyFeedback

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

Parameters:

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

    keyword for initializing values

Options Hash (args):

  • :type (uint8)

    initialize value

  • :id (uint8)

    initialize value

  • :intensity (float32)

    initialize value



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/sensor_msgs/JoyFeedback.rb', line 57

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



44
45
46
# File 'lib/sensor_msgs/JoyFeedback.rb', line 44

def id
  @id
end

#intensityObject

Returns the value of attribute intensity.



44
45
46
# File 'lib/sensor_msgs/JoyFeedback.rb', line 44

def intensity
  @intensity
end

#typeObject

Returns the value of attribute type.



44
45
46
# File 'lib/sensor_msgs/JoyFeedback.rb', line 44

def type
  @type
end

Class Method Details

.md5sumObject



8
9
10
# File 'lib/sensor_msgs/JoyFeedback.rb', line 8

def self.md5sum
  "f4dcd73460360d98f36e55ee7f2e46f1"
end

.typeObject



12
13
14
# File 'lib/sensor_msgs/JoyFeedback.rb', line 12

def self.type
  "sensor_msgs/JoyFeedback"
end

Instance Method Details

#_get_typesString

internal API method

Returns:

  • (String)

    Message type string.



78
79
80
# File 'lib/sensor_msgs/JoyFeedback.rb', line 78

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


95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/sensor_msgs/JoyFeedback.rb', line 95

def deserialize(str)

  begin
    end_point = 0
    start = end_point
    end_point += ROS::Struct::calc_size('C2f')
    (@type, @id, @intensity,) = @@struct_C2f.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/sensor_msgs/JoyFeedback.rb', line 16

def has_header?
  false
end

#message_definitionObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sensor_msgs/JoyFeedback.rb', line 20

def message_definition
  "# Declare of the type of feedback
uint8 TYPE_LED    = 0
uint8 TYPE_RUMBLE = 1
uint8 TYPE_BUZZER = 2

uint8 type

# This will hold an id number for each type of each feedback.
# Example, the first led would be id=0, the second would be id=1
uint8 id

# Intensity of the feedback, from 0.0 to 1.0, inclusive.  If device is
# actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.
float32 intensity


"
end

#serialize(buff) ⇒ Object

serialize message into buffer

Parameters:

  • buff (IO)

    buffer



84
85
86
87
88
89
90
91
# File 'lib/sensor_msgs/JoyFeedback.rb', line 84

def serialize(buff)
  begin
    buff.write(@@struct_C2f.pack(@type, @id, @intensity))
  rescue => exception
    raise "some erro in serialize: #{exception}"

  end
end