ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Here is an example from joystick_drivers https://github.com/ros-drivers/joystick_drivers :

$ rosmsg show sensor_msgs/JoyFeedbackArray 
sensor_msgs/JoyFeedback[] array
uint8 TYPE_LED=0
uint8 TYPE_RUMBLE=1
uint8 TYPE_BUZZER=2
uint8 type
uint8 id
float32 intensity

There is nothing special or required about the constants TYPE_LED and TYPE_RUMBLE being capitalized or having a prefix in common with the field 'type' for which they are supposed to be the values it ought to have.

In https://github.com/ros-drivers/joystick_drivers/blob/groovy-devel/ps3joy/scripts/ps3joy_node.py the usage of the enum like fields is shown:

rospy.Subscriber("joy/set_feedback",sensor_msgs.msg.JoyFeedbackArray,self.set_feedback)
...
def set_feedback(self,msg):
  for feedback in msg.array:
    if feedback.type == sensor_msgs.msg.JoyFeedback.TYPE_LED and feedback.id < 4:
      self.led_values[feedback.id] = int(round(feedback.intensity))
    elif feedback.type == sensor_msgs.msg.JoyFeedback.TYPE_RUMBLE and feedback.id < 2:
...

Here is an example from joystick_drivers https://github.com/ros-drivers/joystick_drivers :

$ rosmsg show sensor_msgs/JoyFeedbackArray 
sensor_msgs/JoyFeedback[] array
uint8 TYPE_LED=0
uint8 TYPE_RUMBLE=1
uint8 TYPE_BUZZER=2
uint8 type
uint8 id
float32 intensity

There is nothing special or required about the constants TYPE_LED and TYPE_RUMBLE being capitalized or having a prefix in common with the field 'type' for which they are supposed to be the values it ought to have.

In https://github.com/ros-drivers/joystick_drivers/blob/groovy-devel/ps3joy/scripts/ps3joy_node.py the usage of the enum like fields is shown:shown for Python:

rospy.Subscriber("joy/set_feedback",sensor_msgs.msg.JoyFeedbackArray,self.set_feedback)
...
def set_feedback(self,msg):
  for feedback in msg.array:
    if feedback.type == sensor_msgs.msg.JoyFeedback.TYPE_LED and feedback.id < 4:
      self.led_values[feedback.id] = int(round(feedback.intensity))
    elif feedback.type == sensor_msgs.msg.JoyFeedback.TYPE_RUMBLE and feedback.id < 2:
...

In C++ it would look like this:

if (msg->waveform == sensor_msgs::JoyFeedback::TYPE_RUMBLE)
...