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

abacas's profile - activity

2014-12-22 12:36:25 -0500 received badge  Nice Answer (source)
2013-04-10 01:20:16 -0500 received badge  Teacher (source)
2012-02-09 19:13:28 -0500 answered a question How to use NodeHandle in callback?

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".