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

Revision history [back]

Add the joy package to your dependencies in your manifest.xml with <depend package="joy"/>, then include the appropriate C++ message header file with #include <joy/Joy.h>, and change the callback to

void myCallback (const joy::Joy::ConstPtr& msg)
{
}

If the joy::Joy construct seems weird, that's because messages usually are in a namespace that is named after the package. The String message belongs to the package std_msgs, and the Joy message belongs to the package joy.

Add the joy package to your dependencies in your manifest.xml with <depend package="joy"/>package="sensor_msgs"/>, then include the appropriate C++ message header file with #include <joy/Joy.h><sensor_msgs/Joy.h>, and change the callback to

void myCallback (const joy::Joy::ConstPtr& sensor_msgs::Joy::ConstPtr& msg)
{
}

If the joy::Joy construct seems weird, that's because messages usually are in a namespace that is named after the package. The String message belongs to the package std_msgs, and the Joy message belongs to the package joy.

Add the joysensor_msgs package to your dependencies in your manifest.xml with <depend package="sensor_msgs"/>, then include the appropriate C++ message header file with #include <sensor_msgs/Joy.h>, and change the callback to

void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
{
}

Add the sensor_msgs package to your dependencies in your manifest.xml with <depend package="sensor_msgs"/>, then include the appropriate C++ message header file with #include <sensor_msgs/Joy.h>, and change the callback to

void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
{
  for (int i = 0; i < joy->axes.size(); ++i) {
    ROS_INFO("Axis %d is now at position %f", i, joy->axes[i]);
  }
}

Add the sensor_msgs package to your dependencies in your manifest.xml with <depend package="sensor_msgs"/>, then include the appropriate C++ message header file with #include <sensor_msgs/Joy.h>, and change the callback to

void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
{
  for (int (unsigned i = 0; i < joy->axes.size(); ++i) {
    ROS_INFO("Axis %d is now at position %f", i, joy->axes[i]);
  }
}

Add the sensor_msgs package to your dependencies in your manifest.xml with <depend package="sensor_msgs"/>, then include the appropriate C++ message header file with #include <sensor_msgs/Joy.h>, and change the callback to

void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
{
  for (unsigned i = 0; i < joy->axes.size(); msg->axes.size(); ++i) {
    ROS_INFO("Axis %d is now at position %f", i, joy->axes[i]);
msg->axes[i]);
  }
}