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

I think you misunderstood how subscribers works because you made a little confusion about how to receive the data. The first time using rospy.wait_for_message('cmd_vel_1', Twist) the variable action is propperly assigned the value of the message from the topic cmd_vel but then with this line :

action = rospy.Subscriber('cmd_vel_1', Twist, queue_size=10)

You don't get the message from cmd_vel_1 like that. This defines the subscriber to the cmd_vel_1 topic and you can get the data using a callback function (which you don't define when declaring the subscriber). So the varaible action is not correctly set.

You should use the same template as in the tutorials. Simply create a callback function when declaring the subscriber (you should replace the wait_for_message line with the declaration of the subscriber) and it should be working fine.