ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You must initialize the NodeHandle in the "main" function (or in any method called indirectly or directly by the main function). I sometimes declare a pointer to the NodeHandle as global variable to my program and then initialize it afterwards in the main. But it will work as you have it right now.
Regarding the ROS Subscriber, try replacing the declaration of the Subscriber by this:
ros::Subscriber sub = n.subscribe<std_msgs::String>("joy_vel_output", 1000, &joyCallback);
Be always aware of the namespace of your subscribed or advertised topic. I normally use an absolute path to the topic name, so I would have subscribed to "/joy_vel_output" instead of "joy_vel_output".