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

Revision history [back]

click to hide/show revision 1
initial version

Move all initialisation of publishers / subscribers out of your joy_talker callback. Only publish messages inside callbacks, never (well .. never ..) create anything related to message publication and / or subscription in them. Also: no node initialisation statements inside callbacks.

Callbacks are called upon reception of a message, a single message. How do you expect the code you posted to work? Upon reception of the first Joy msg, your callback will be invoked, which (ignoring the call to rospy.init_node(..) for now) then enters an (potentially) infinite while-loop. pub.publish(..) will never be invoked.

Move all initialisation of publishers / subscribers out of your joy_talker callback. Only publish messages inside callbacks, never (well .. never ..) create anything related to message publication and / or subscription in them. Also: no node initialisation statements inside callbacks.

Callbacks are called upon reception of a message, a single message. How do you expect the code you posted to work? Upon reception of the first Joy msg, your callback will be invoked, which (ignoring the call to rospy.init_node(..) for now) then enters an (potentially) infinite while-loop. pub.publish(..) will never be invoked.


Edit: if you based your code on the example from the link you posted, where did the extra while-loop and node initialisation come from? As you can see in the xbox example, the msg callback only performs some very simple calculations, before publishing a new message.