ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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.
2 | No.2 Revision |
Add the joy package to your dependencies in your manifest.xml
with <depend
, then include the appropriate C++ message header file with package="joy"/>package="sensor_msgs"/>#include
, and change the callback to<joy/Joy.h><sensor_msgs/Joy.h>
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.
3 | No.3 Revision |
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)
{
}
4 | No.4 Revision |
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]);
}
}
5 | No.5 Revision |
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]);
}
}
6 | No.6 Revision |
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]);
}
}