How to use sensor_msgs/Joy instead of joystick_drivers/Joy?
Hi, I want to migrate my joystick programs from deprecated joystick_drivers to sensor_msgs equivalent.
When I used joystick_drivers I run an executable joy_node..., then a node "joy_node" was created to publish the Joy msg (I just suscribe to it and was simple)...
but... with sensor_msgs equivalent, I don't know what executable do I have to run to see a publisher node giving me the Joy msgs... I have tried the following simple listener..., but I simply can't see anybody (with rostopic & rxgraph) publishing Joy msgs...
Thanks for your help!
#include <ros/ros.h>
#include <sensor_msgs/Joy.h>
void myCallback (const sensor_msgs::Joy::ConstPtr& msg)
{
for (unsigned i = 0; i < msg->axes.size(); ++i) {
ROS_INFO("Axis %d is now at position %f", i, msg->axes[i]);
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("joy", 1000, myCallback);
ros::spin();
return 0;
}